ld --eh-frame-hdr

Dan Williams thermostat@gmail.com
Mon Jun 16 22:40:00 GMT 2008


Hi,

I have a question about the behavior of ld's --eh-frame-hdr switch
when used with static linking.

I have a simple c++ program I'm compiling as so:

$ g++ -Wl,--eh-frame-hdr --static hello.cpp -o hello

checking readelf -l, it lists the following segments:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08048000 0xed591 0xed591 R E 0x1000
  LOAD           0x0ed594 0x08136594 0x08136594 0x01060 0x08670 RW  0x1000
  NOTE           0x0000d4 0x080480d4 0x080480d4 0x00020 0x00020 R   0x4
  TLS            0x0ed594 0x08136594 0x08136594 0x00010 0x00030 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

when I compile the program dynamically, (even without -Wl,--eh-frame-hdr) I get:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x08048134 0x08048134 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x0088c 0x0088c R E 0x1000
  LOAD           0x00088c 0x0804988c 0x0804988c 0x00134 0x001c8 RW  0x1000
  DYNAMIC        0x0008a4 0x080498a4 0x080498a4 0x000e0 0x000e0 RW  0x4
  NOTE           0x000148 0x08048148 0x08048148 0x00020 0x00020 R   0x4
  GNU_EH_FRAME   0x0007c4 0x080487c4 0x080487c4 0x0002c 0x0002c R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

I'm trying to use libunwind with a statically built program, and I've
determined that it needs the GNU_EH_FRAME segment to correctly find
the handler (personality) routine. Is there a way to get ld to emit
this segment in a statically linked program? I've tried this with ld
version 2.15 and ld version 2.17.50.0.3-6, with the same results (and
ideally, I'd like a solution that works with both versions). Any
advice would be greatly appreciated.

-Dan



More information about the Binutils mailing list