https://sourceware.org/bugzilla/show_bug.cgi?id=34003

            Bug ID: 34003
           Summary: --rosegment puts read-only data in code segment
           Product: binutils
           Version: 2.47 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
                CC: r at hev dot cc
  Target Milestone: ---

-pie -z separate-code --no-rosegment generates:

Elf file type is DYN (Position-Independent Executable file)
Entry point 0x1050
There are 13 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x001a0 0x001a0 R   0x4
  INTERP         0x0001f8 0x000001f8 0x000001f8 0x0001a 0x0001a R   0x1
      [Requesting program interpreter: /libx32/ld-linux-x32.so.2]
  LOAD           0x000000 0x00000000 0x00000000 0x00404 0x00404 R   0x1000
  LOAD           0x001000 0x00001000 0x00001000 0x00161 0x00161 R E 0x1000
  LOAD           0x002000 0x00002000 0x00002000 0x00114 0x00114 R   0x1000
  LOAD           0x002eac 0x00003eac 0x00003eac 0x00160 0x00164 RW  0x1000
  DYNAMIC        0x002eb8 0x00003eb8 0x00003eb8 0x00108 0x00108 RW  0x4
  NOTE           0x0001d4 0x000001d4 0x000001d4 0x00024 0x00024 R   0x4
  NOTE           0x0020c0 0x000020c0 0x000020c0 0x00054 0x00054 R   0x4
  GNU_PROPERTY   0x0020c0 0x000020c0 0x000020c0 0x00034 0x00034 R   0x4
  GNU_EH_FRAME   0x00200c 0x0000200c 0x0000200c 0x0002c 0x0002c R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x002eac 0x00003eac 0x00003eac 0x00154 0x00154 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .note.gnu.build-id .interp .gnu.hash .dynsym .dynstr .gnu.version
.gnu.version_r .rela.dyn .rela.plt 
   03     .init .plt .plt.got .text .fini 
   04     .rodata .eh_frame_hdr .eh_frame .note.gnu.property .note.ABI-tag 
   05     .init_array .fini_array .data.rel.ro .dynamic .got .got.plt .data
.bss 
   06     .dynamic 
   07     .note.gnu.build-id 
   08     .note.gnu.property .note.ABI-tag 
   09     .note.gnu.property 
   10     .eh_frame_hdr 
   11     
   12     .init_array .fini_array .data.rel.ro .dynamic .got 

-pie -z separate-code --rosegment generates:

Elf file type is DYN (Position-Independent Executable file)
Entry point 0x230
There are 12 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x00180 0x00180 R   0x4
  INTERP         0x001000 0x00001000 0x00001000 0x0001a 0x0001a R   0x1
      [Requesting program interpreter: /libx32/ld-linux-x32.so.2]
  LOAD           0x000000 0x00000000 0x00000000 0x00341 0x00341 R E 0x1000
  LOAD           0x001000 0x00001000 0x00001000 0x00320 0x00320 R   0x1000
  LOAD           0x001eac 0x00002eac 0x00002eac 0x00160 0x00164 RW  0x1000
  DYNAMIC        0x001eb8 0x00002eb8 0x00002eb8 0x00108 0x00108 RW  0x4
  NOTE           0x0001b4 0x000001b4 0x000001b4 0x00024 0x00024 R   0x4
  NOTE           0x0012cc 0x000012cc 0x000012cc 0x00054 0x00054 R   0x4
  GNU_PROPERTY   0x0012cc 0x000012cc 0x000012cc 0x00034 0x00034 R   0x4
  GNU_EH_FRAME   0x001218 0x00001218 0x00001218 0x0002c 0x0002c R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x001eac 0x00002eac 0x00002eac 0x00154 0x00154 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .note.gnu.build-id .init .plt .plt.got .text .fini 
   03     .interp .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r
.rela.dyn .rela.plt .rodata .eh_frame_hdr .eh_frame .note.gnu.property
.note.ABI-tag 
   04     .init_array .fini_array .data.rel.ro .dynamic .got .got.plt .data
.bss 
   05     .dynamic 
   06     .note.gnu.build-id 
   07     .note.gnu.property .note.ABI-tag 
   08     .note.gnu.property 
   09     .eh_frame_hdr 
   10     
   11     .init_array .fini_array .data.rel.ro .dynamic .got 

The read-only PHDR and INTERP segments are placed in the executable segment,
which defeats the purpose of -z separate-code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to