NetBSD Problem Report #43856

From  Wed Sep  8 21:05:05 2010
Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id 7289A63BC80
	for <>; Wed,  8 Sep 2010 21:05:05 +0000 (UTC)
Message-Id: <>
Date: Wed,  8 Sep 2010 21:05:04 +0000 (UTC)
Subject: some executables have all loaded sections executable
X-Send-Pr-Version: 3.95

>Number:         43856
>Category:       toolchain
>Synopsis:       some executables have all loaded sections executable
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 08 21:10:00 +0000 2010
>Last-Modified:  Fri Sep 21 01:50:05 +0000 2012
>Originator:     Martin Husemann
>Release:        NetBSD 5.99.39
The NetBSD Foundation, Inc.
System: NetBSD 5.99.39 NetBSD 5.99.39 (GENERIC) #52: Wed Sep 8 22:43:54 CEST 2010 sparc64
Architecture: sparc64
Machine: sparc64

Note how some binaries have all loadable sections marked as executable:

/usr/pkg/bin/tcsh:     file format elf64-sparc

Program Header:
    PHDR off    0x0000000000000040 vaddr 0x0000000000100040 paddr 0x0000000000100040 align 2**3
         filesz 0x0000000000000150 memsz 0x0000000000000150 flags r-x
  INTERP off    0x0000000000000190 vaddr 0x0000000000100190 paddr 0x0000000000100190 align 2**0
         filesz 0x0000000000000017 memsz 0x0000000000000017 flags r--
    LOAD off    0x0000000000000000 vaddr 0x0000000000100000 paddr 0x0000000000100000 align 2**20
         filesz 0x00000000000505b4 memsz 0x00000000000505b4 flags r-x
    LOAD off    0x0000000000052000 vaddr 0x0000000000252000 paddr 0x0000000000252000 align 2**20
         filesz 0x0000000000004530 memsz 0x0000000000019a10 flags rwx
 DYNAMIC off    0x0000000000052028 vaddr 0x0000000000252028 paddr 0x0000000000252028 align 2**3
         filesz 0x00000000000001b0 memsz 0x00000000000001b0 flags rw-
    NOTE off    0x00000000000001a8 vaddr 0x00000000001001a8 paddr 0x00000000001001a8 align 2**2
         filesz 0x000000000000002c memsz 0x000000000000002c flags r--

Dynamic Section:
  RPATH                /usr/pkg/lib
  INIT                 0x0000000000102c70
  FINI                 0x0000000000149dc0
  HASH                 0x00000000001001d8
  STRTAB               0x00000000001016f8
  SYMTAB               0x00000000001006a8
  STRSZ                0x0000000000000611
  SYMENT               0x0000000000000018
  DEBUG                0x0000000000000000
  PLTGOT               0x0000000000252300
  PLTRELSZ             0x0000000000000e70
  PLTREL               0x0000000000000007
  JMPREL               0x0000000000101e00
  RELA                 0x0000000000101d10
  RELASZ               0x0000000000000f60
  RELAENT              0x0000000000000018
  0x70000001           0x0000000000000001
  0x70000001           0x0000000000000002

Build shells/tcsh from pkgsrc on some risc platform (exact triggers unknown)



From: Martin Husemann <>
Subject: Re: toolchain/43856: some executables have all loaded sections executable
Date: Fri, 10 Sep 2010 08:55:37 +0200

 More data and some correction: "some" binary basically means "all binaries",
 it just wasn't that obvious because not everything uses break()/sbreak() and
 therefore didn't fail during recent exec_elf.c changes.

 More data below.

 As long as there is no non-executable PLT format for some archs, should we
 fix the default linker scripts to move .plt and .data into different segments?


 Here is an arbitrary example:

 readelf -l /usr/obj/bin/ls/ls

 Elf file type is EXEC (Executable file)
 Entry point 0x101200
 There are 6 program headers, starting at offset 64

 Program Headers:
   Type           Offset             VirtAddr           PhysAddr
                  FileSiz            MemSiz              Flags  Align
   PHDR           0x0000000000000040 0x0000000000100040 0x0000000000100040
                  0x0000000000000150 0x0000000000000150  R E    8
   INTERP         0x0000000000000190 0x0000000000100190 0x0000000000100190
                  0x0000000000000013 0x0000000000000013  R      1
       [Requesting program interpreter: /libexec/ld.elf_so]
   LOAD           0x0000000000000000 0x0000000000100000 0x0000000000100000
                  0x000000000000485c 0x000000000000485c  R E    100000
   LOAD           0x0000000000004860 0x0000000000204860 0x0000000000204860
                  0x00000000000009dc 0x0000000000000ca0  RWE    100000
   DYNAMIC        0x0000000000004888 0x0000000000204888 0x0000000000204888
                  0x00000000000001a0 0x00000000000001a0  RW     8
   NOTE           0x00000000000001a4 0x00000000001001a4 0x00000000001001a4
                  0x000000000000002c 0x000000000000002c  R      4

  Section to Segment mapping:
   Segment Sections...
    01     .interp 
    02     .interp .note.netbsd.ident .note.netbsd.pax .hash .dynsym .dynstr .rela.dyn .rela.plt .init .text .fini .rodata .eh_frame 
    03     .ctors .dtors .jcr .dynamic .got .plt .data .bss 
    04     .dynamic 
    05     .note.netbsd.ident .note.netbsd.pax 

 And the link map:

 #      link  ls/ls
 /usr/tools/bin/sparc64--netbsd-gcc  -B//usr/lib/ -B//usr/lib/  -Wl,-nostdlib   -Wl,--print-map -Wl,--fatal-warnings     -o ls  cmp.o ls.o main.o print.o util.o -lutil      -L//usr/lib   -Wl,-dynamic-linker=/libexec/ld.elf_so -Wl,-rpath-link,//lib  -R/lib  -L//lib -Wl,-rpath-link,//usr/lib  -L//usr/lib

 Allocating common symbols
 Common symbol       size              file

 f_size              0x4               ls.o
 f_nonprint          0x4               ls.o
 f_grouponly         0x4               ls.o
 f_column            0x4               ls.o
 f_listdir           0x4               ls.o
 f_whiteout          0x4               ls.o
 f_nosort            0x4               ls.o
 f_octal_escape      0x4               ls.o
 f_longform          0x4               ls.o
 f_type              0x4               ls.o
 f_singlecol         0x4               ls.o
 f_typedir           0x4               ls.o
 f_recursive         0x4               ls.o
 blocksize           0x8               ls.o
 f_numericonly       0x4               ls.o
 f_sectime           0x4               ls.o
 f_stream            0x4               ls.o
 environ             0x8               //usr/lib/crt0.o
 f_listdot           0x4               ls.o
 f_accesstime        0x4               ls.o
 f_flags             0x4               ls.o
 f_octal             0x4               ls.o
 f_humanize          0x4               ls.o
 f_columnacross      0x4               ls.o
 f_reversesort       0x4               ls.o
 f_inode             0x4               ls.o
 f_statustime        0x4               ls.o

 Memory Configuration

 Name             Origin             Length             Attributes
 *default*        0x0000000000000000 0xffffffffffffffff

 Linker script and memory map

 LOAD //usr/lib/crt0.o
 LOAD //usr/lib/crti.o
 LOAD //usr/lib/crtbegin.o
 LOAD cmp.o
 LOAD ls.o
 LOAD main.o
 LOAD print.o
 LOAD util.o
 LOAD //usr/lib/
 LOAD //usr/lib/libgcc.a
 LOAD //usr/lib/libgcc_eh.a
 LOAD //usr/lib/
 LOAD //usr/lib/libgcc.a
 LOAD //usr/lib/libgcc_eh.a
 LOAD //usr/lib/
 LOAD //usr/lib/crtend.o
 LOAD //usr/lib/crtn.o
                 0x0000000000100000                PROVIDE (__executable_start, 0x100000)
                 0x0000000000100190                . = (0x100000 + SIZEOF_HEADERS)

 .interp         0x0000000000100190       0x13
  .interp        0x0000000000100190       0x13 //usr/lib/crt0.o

                 0x00000000001001a4       0x18
                 0x00000000001001a4       0x18 //usr/lib/crti.o

                 0x00000000001001bc       0x14
                 0x00000000001001bc       0x14 //usr/lib/crti.o

 .hash           0x00000000001001d0      0x1a4
  .hash          0x00000000001001d0      0x1a4 //usr/lib/crt0.o


 .dynsym         0x0000000000100378      0x630
  .dynsym        0x0000000000100378      0x630 //usr/lib/crt0.o

 .dynstr         0x00000000001009a8      0x267
  .dynstr        0x00000000001009a8      0x267 //usr/lib/crt0.o

 .gnu.version    0x0000000000100c10        0x0 load address 0x0000000000100c0f
  .gnu.version   0x0000000000000000        0x0 //usr/lib/crt0.o

 .gnu.version_d  0x0000000000100c10        0x0 load address 0x0000000000100c0f
                 0x0000000000000000        0x0 //usr/lib/crt0.o

 .gnu.version_r  0x0000000000100c10        0x0 load address 0x0000000000100c0f
                 0x0000000000000000        0x0 //usr/lib/crt0.o

  *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
  *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
  *(* .rel.gnu.linkonce.d.*)
  *(.rel.tdata .rel.tdata.**)
  *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
  *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)

 .rela.dyn       0x0000000000100c10       0xf0
  *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
  .rela.text     0x0000000000000000        0x0 //usr/lib/crt0.o
  *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
  *(* .rela.gnu.linkonce.d.*)
  *(.rela.tdata .rela.tdata.**)
  *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
  *(      0x0000000000100c10       0xa8 //usr/lib/crt0.o
  *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
  .rela.bss      0x0000000000100cb8       0x48 //usr/lib/crt0.o


 .rela.plt       0x0000000000100d00      0x4e0
  .rela.plt      0x0000000000100d00      0x4e0 //usr/lib/crt0.o

 .init           0x00000000001011e0       0x1c
  .init          0x00000000001011e0        0x4 //usr/lib/crti.o
                 0x00000000001011e0                _init
  .init          0x00000000001011e4        0x8 //usr/lib/crtbegin.o
  .init          0x00000000001011ec        0x8 //usr/lib/crtend.o
  .init          0x00000000001011f4        0x8 //usr/lib/crtn.o

 .text           0x0000000000101200     0x3440
  *(.text .stub .text.* .gnu.linkonce.t.*)
  .text          0x0000000000101200      0x240 //usr/lib/crt0.o
                 0x0000000000101200                _start
                 0x00000000001012e0                ___start
                 0x0000000000101240                _rtld_setup
                 0x0000000000101200                __start
  .text          0x0000000000101440        0x0 //usr/lib/crti.o
  .text          0x0000000000101440      0x180 //usr/lib/crtbegin.o
  .text          0x00000000001015c0      0x300 cmp.o
                 0x0000000000101740                namecmp
                 0x0000000000101760                sizecmp
                 0x0000000000101680                revacccmp
                 0x0000000000101620                revstatcmp
                 0x0000000000101800                acccmp
                 0x00000000001017a0                statcmp
                 0x00000000001015e0                revsizecmp
                 0x0000000000101860                modcmp
                 0x00000000001015c0                revnamecmp
                 0x00000000001016e0                revmodcmp
  .text          0x00000000001018c0     0x12c0 ls.o
                 0x0000000000102380                ls_main
  .text          0x0000000000102b80       0x20 main.o
                 0x0000000000102b80                main
  .text          0x0000000000102ba0     0x16e0 print.o
                 0x0000000000103a80                printstream
                 0x00000000001034e0                printlong
                 0x0000000000103100                printscol
                 0x0000000000103cc0                printacol
                 0x0000000000103f20                printcol
  .text          0x0000000000104280      0x320 util.o
                 0x00000000001044e0                safe_print
                 0x0000000000104380                printescaped
                 0x0000000000104280                usage
  .text          0x00000000001045a0       0xa0 //usr/lib/crtend.o
  .text          0x0000000000104640        0x0 //usr/lib/crtn.o

 .fini           0x0000000000104640       0x14
  .fini          0x0000000000104640        0x4 //usr/lib/crti.o
                 0x0000000000104640                _fini
  .fini          0x0000000000104644        0x8 //usr/lib/crtbegin.o
  .fini          0x000000000010464c        0x8 //usr/lib/crtn.o
                 0x0000000000104654                PROVIDE (__etext, .)
                 0x0000000000104654                PROVIDE (_etext, .)
                 0x0000000000104654                PROVIDE (etext, .)

 .rodata         0x0000000000104658      0x200
  *(.rodata .rodata.* .gnu.linkonce.r.*)
                 0x0000000000104658       0x49 //usr/lib/crt0.o
                                          0x58 (size before relaxing)
  *fill*         0x00000000001046a1        0x7 00
                 0x00000000001046a8       0x81 ls.o
                                          0x90 (size before relaxing)
  .rodata        0x0000000000104729        0x0 ls.o
  *fill*         0x0000000000104729        0x7 00
                 0x0000000000104730       0xbd print.o
                                          0xc8 (size before relaxing)
  *fill*         0x00000000001047ed        0x3 00
                 0x00000000001047f0       0x68 util.o
                                          0x70 (size before relaxing)



 .eh_frame       0x0000000000104858        0x4
  .eh_frame      0x0000000000104858        0x0 //usr/lib/crtbegin.o
  .eh_frame      0x0000000000104858        0x4 //usr/lib/crtend.o

  *(.gcc_except_table .gcc_except_table.*)
                 0x000000000010485c                . = (ALIGN (0x100000) - ((0x100000 - .) & 0xfffff))
                 0x000000000020485c                . = (0x100000 DATA_SEGMENT_ALIGN 0x2000)


  *(.gcc_except_table .gcc_except_table.*)

  *(.tdata .tdata.**)

  *(.tbss .tbss.* .gnu.linkonce.tb.*)

 .preinit_array  0x000000000020485c        0x0
                 0x000000000020485c                PROVIDE (__preinit_array_start, .)
                 0x000000000020485c                PROVIDE (__preinit_array_end, .)

 .init_array     0x000000000020485c        0x0
                 0x000000000020485c                PROVIDE (__init_array_start, .)
                 0x000000000020485c                PROVIDE (__init_array_end, .)

 .fini_array     0x000000000020485c        0x0
                 0x000000000020485c                PROVIDE (__fini_array_start, .)
                 0x000000000020485c                PROVIDE (__fini_array_end, .)

 .ctors          0x0000000000204860       0x10
  .ctors         0x0000000000204860        0x8 //usr/lib/crtbegin.o
  *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  .ctors         0x0000000000204868        0x8 //usr/lib/crtend.o

 .dtors          0x0000000000204870       0x10
  .dtors         0x0000000000204870        0x8 //usr/lib/crtbegin.o
  *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  .dtors         0x0000000000204878        0x8 //usr/lib/crtend.o

 .jcr            0x0000000000204880        0x8
  .jcr           0x0000000000204880        0x0 //usr/lib/crtbegin.o
  .jcr           0x0000000000204880        0x8 //usr/lib/crtend.o

 .dynamic        0x0000000000204888      0x1a0
  .dynamic       0x0000000000204888      0x1a0 //usr/lib/crt0.o
                 0x0000000000204888                _DYNAMIC
                 0x0000000000204a28                . = (. DATA_SEGMENT_RELRO_END 0x0)

 .got            0x0000000000204a28       0x90
  .got           0x0000000000204a28       0x90 //usr/lib/crt0.o
                 0x0000000000204a28                _GLOBAL_OFFSET_TABLE_

 .plt            0x0000000000204b00      0x700
  .plt           0x0000000000204b00      0x700 //usr/lib/crt0.o
                 0x0000000000204b80                getbsize
                 0x0000000000204ba0                errx
                 0x0000000000204be0                user_from_uid
                 0x0000000000204c00                getenv
                 0x0000000000204c20                fwrite
                 0x0000000000204c40                realloc
                 0x0000000000204c60                group_from_gid
                 0x0000000000204c80                readlink
                 0x0000000000204ca0                __ctime50
                 0x0000000000204cc0                __fts_read60
                 0x0000000000204ce0                flags_to_string
                 0x0000000000204d00                __time50
                 0x0000000000204d20                malloc
                 0x0000000000204d40                __fts_set60
                 0x0000000000204d60                ioctl
                 0x0000000000204d80                strlen
                 0x0000000000204da0                snprintf
                 0x0000000000204dc0                atexit
                 0x0000000000204de0                strmode
                 0x0000000000204e00                wcwidth
                 0x0000000000204e20                __fts_close60
                 0x0000000000204e40                warnx
                 0x0000000000204e60                mbrtowc
                 0x0000000000204e80                isatty
                 0x0000000000204ea0                iswprint
                 0x0000000000204ec0                err
                 0x0000000000204ee0                humanize_number
                 0x0000000000204f00                memset
                 0x0000000000204f20                __setlocale50
                 0x0000000000204f40                wcrtomb
                 0x0000000000204f60                getuid
                 0x0000000000204f80                fprintf
                 0x0000000000204fa0                getprogname
                 0x0000000000204fc0                __syscall
                 0x0000000000204fe0                __swbuf
                 0x0000000000205000                exit
                 0x0000000000205020                setprogname
                 0x0000000000205040                __fts_open60
                 0x0000000000205060                strcmp
                 0x0000000000205080                getopt
                 0x00000000002050a0                strvis
                 0x00000000002050c0                __errno
                 0x00000000002050e0                free
                 0x0000000000205100                atoi
                 0x0000000000204b00                _PROCEDURE_LINKAGE_TABLE_
                 0x0000000000205120                strerror
                 0x0000000000205140                printf
                 0x0000000000205160                warn
                 0x00000000002051a0                strcpy
                 0x00000000002051e0                __fts_children60

 .data           0x0000000000205200       0x3c
  *(.data .data.* .gnu.linkonce.d.*)
  .data          0x0000000000205200        0x0 //usr/lib/crt0.o
                 0x0000000000205200        0x8 //usr/lib/crt0.o
                 0x0000000000205200                __progname
  .data          0x0000000000205208        0x0 //usr/lib/crti.o
  .data          0x0000000000205208        0x8 //usr/lib/crtbegin.o
                 0x0000000000205208                __dso_handle
                 0x0000000000205210        0x8 //usr/lib/crtbegin.o
  .data          0x0000000000205218        0x0 cmp.o
  .data          0x0000000000205218       0x20 ls.o
                 0x0000000000205218                termwidth
  .data          0x0000000000205238        0x0 main.o
  .data          0x0000000000205238        0x4 print.o
  .data          0x000000000020523c        0x0 util.o
  .data          0x000000000020523c        0x0 //usr/lib/crtend.o
  .data          0x000000000020523c        0x0 //usr/lib/crtn.o

                 0x000000000020523c                _edata = .
                 0x000000000020523c                PROVIDE (edata, .)
                 0x000000000020523c                __bss_start = .

 .bss            0x0000000000205240      0x2c0
  .dynbss        0x0000000000205240      0x1d4 //usr/lib/crt0.o
                 0x0000000000205240                __sF
                 0x0000000000205408                __mb_cur_max
                 0x0000000000205410                optind
  *(.bss .bss.* .gnu.linkonce.b.*)
  *fill*         0x0000000000205414        0x4 00
  .bss           0x0000000000205418        0x8 //usr/lib/crt0.o
                 0x0000000000205418                __ps_strings
  .bss           0x0000000000205420        0x0 //usr/lib/crti.o
  .bss           0x0000000000205420       0x38 //usr/lib/crtbegin.o
  .bss           0x0000000000205458        0x0 cmp.o
  .bss           0x0000000000205458       0x20 ls.o
                 0x0000000000205458                sortkey
                 0x000000000020545c                rval
  .bss           0x0000000000205478        0x0 main.o
  .bss           0x0000000000205478       0x10 print.o
  .bss           0x0000000000205488        0x0 util.o
  .bss           0x0000000000205488        0x0 //usr/lib/crtend.o
  .bss           0x0000000000205488        0x0 //usr/lib/crtn.o
  COMMON         0x0000000000205488        0x8 //usr/lib/crt0.o
                 0x0000000000205488                environ
  COMMON         0x0000000000205490       0x70 ls.o
                 0x0000000000205490                f_size
                 0x0000000000205494                f_nonprint
                 0x0000000000205498                f_grouponly
                 0x000000000020549c                f_column
                 0x00000000002054a0                f_listdir
                 0x00000000002054a4                f_whiteout
                 0x00000000002054a8                f_nosort
                 0x00000000002054ac                f_octal_escape
                 0x00000000002054b0                f_longform
                 0x00000000002054b4                f_type
                 0x00000000002054b8                f_singlecol
                 0x00000000002054bc                f_typedir
                 0x00000000002054c0                f_recursive
                 0x00000000002054c8                blocksize
                 0x00000000002054d0                f_numericonly
                 0x00000000002054d4                f_sectime
                 0x00000000002054d8                f_stream
                 0x00000000002054dc                f_listdot
                 0x00000000002054e0                f_accesstime
                 0x00000000002054e4                f_flags
                 0x00000000002054e8                f_octal
                 0x00000000002054ec                f_humanize
                 0x00000000002054f0                f_columnacross
                 0x00000000002054f4                f_reversesort
                 0x00000000002054f8                f_inode
                 0x00000000002054fc                f_statustime
                 0x0000000000205500                . = ALIGN ((. != 0x0)?0x8:0x1)
                 0x0000000000205500                . = ALIGN (0x8)
                 0x0000000000205500                . = ALIGN (0x8)
                 0x0000000000205500                _end = .
                 0x0000000000205500                PROVIDE (end, .)
                 0x0000000000205500                . = DATA_SEGMENT_END (.)







 .comment        0x0000000000000000      0x26c
  .comment       0x0000000000000000       0x3e //usr/lib/crt0.o
  .comment       0x000000000000003e       0x3e //usr/lib/crti.o
  .comment       0x000000000000007c       0x3e //usr/lib/crtbegin.o
  .comment       0x00000000000000ba       0x3e cmp.o
  .comment       0x00000000000000f8       0x3e ls.o
  .comment       0x0000000000000136       0x3e main.o
  .comment       0x0000000000000174       0x3e print.o
  .comment       0x00000000000001b2       0x3e util.o
  .comment       0x00000000000001f0       0x3e //usr/lib/crtend.o
  .comment       0x000000000000022e       0x3e //usr/lib/crtn.o







  *(.debug_info .gnu.linkonce.wi.*)














 OUTPUT(ls elf64-sparc)

 .ident          0x0000000000000000      0x145
  .ident         0x0000000000000000       0x37 //usr/lib/crt0.o
  .ident         0x0000000000000037       0x34 cmp.o
  .ident         0x000000000000006b       0x35 ls.o
  .ident         0x00000000000000a0       0x37 main.o
  .ident         0x00000000000000d7       0x38 print.o
  .ident         0x000000000000010f       0x36 util.o

 .copyright      0x0000000000000000       0x67
  .copyright     0x0000000000000000       0x67 ls.o

State-Changed-From-To: open->feedback
State-Changed-When: Sat, 31 Dec 2011 20:46:48 +0000
Did the new binutils do anything about this?

State-Changed-From-To: feedback->closed
State-Changed-When: Thu, 20 Sep 2012 22:18:58 +0000
apparently not.  sparc64 netbsd-6 /bin/ls still has both LOAD marked executable.

State-Changed-From-To: closed->open
State-Changed-When: Fri, 21 Sep 2012 01:50:05 +0000
oops, i meant to feedback->open this.


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.