https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249121

Konstantin Belousov <k...@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |d...@freebsd.org,
                   |                            |ema...@freebsd.org

--- Comment #4 from Konstantin Belousov <k...@freebsd.org> ---
Clang+lld produce very strange binary when all linked libraries are static:

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

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flg    Align
  PHDR           0x0000000000000040 0x0000000000200040 0x0000000000200040
                 0x0000000000000268 0x0000000000000268  R      0x8
  INTERP         0x00000000000002a8 0x00000000002002a8 0x00000000002002a8
                 0x0000000000000015 0x0000000000000015  R      0x1
      [Requesting program interpreter: /libexec/ld-elf.so.1]
  LOAD           0x0000000000000000 0x0000000000200000 0x0000000000200000
                 0x000000000002279c 0x000000000002279c  R      0x1000
  LOAD           0x00000000000227a0 0x00000000002237a0 0x00000000002237a0
                 0x0000000000091760 0x0000000000091760  R E    0x1000
  LOAD           0x00000000000b3f00 0x00000000002b5f00 0x00000000002b5f00
                 0x0000000000001898 0x0000000000001898  RW     0x1000
  LOAD           0x00000000000b57a0 0x00000000002b87a0 0x00000000002b87a0
                 0x00000000000037c0 0x00000000002247a9  RW     0x1000
  TLS            0x00000000000b3f00 0x00000000002b5f00 0x00000000002b5f00
                 0x0000000000001850 0x0000000000001870  R      0x10
  GNU_RELRO      0x00000000000b3f00 0x00000000002b5f00 0x00000000002b5f00
                 0x0000000000001898 0x0000000000002100  R      0x1
  GNU_EH_FRAME   0x000000000000fc80 0x000000000020fc80 0x000000000020fc80
                 0x000000000000300c 0x000000000000300c  R      0x4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0
  NOTE           0x00000000000002c0 0x00000000002002c0 0x00000000002002c0
                 0x0000000000000048 0x0000000000000048  R      0x4

...

There is no dynamic section in this file.

Relocation section with addend (.rela.dyn):
r_offset     r_info       r_type              st_value         st_name +
r_addend
0000002bbf50 000000000025 R_X86_64_IRELATIVE  0000000000000000  + 223dd0
0000002bbf58 000000000025 R_X86_64_IRELATIVE  0000000000000000  + 2a91e0

As you see, it specifies PHDR INTERP, which brings rtld into action.
But there is no dynamic segment, so rtld cannot see any relocs, which results
in the IRELATIVE relocation sites to still point to the resolver functions.
This is arguably a bug in lld.

There are also two bugs in rtld which fixes I will commit shortly.  I assumes
dynamic segment is there and dereferences NULL pointer otherwise.  Also, it
terminates the image if there is no dynamic symbol table.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"

Reply via email to