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

            Bug ID: 30137
           Summary: LD --dynamicbase does not generate relocation info
           Product: binutils
           Version: 2.40
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: pali at kernel dot org
  Target Milestone: ---

LD --dynamicbase does not work correctly for PE executables. It does not
generate relocation info. Without relocation info in PE binary, it is not
possible to relocate base address. Which makes dynamic base non-working.

Test case which calls external function "external()" from external.dll which
needs to be relocated at runtime.

$ x86_64-w64-mingw32-ld -v
GNU ld (GNU Binutils) 2.40

$ cat external.def
LIBRARY "external.dll"
EXPORTS
external

$ cat test-dynamicbase.S
.globl  main
main:
        call    *__imp_external(%rip)
        mov     $0, %rax
        ret

$ x86_64-w64-mingw32-dlltool -d external.def -l external.dll.a

$ x86_64-w64-mingw32-as test-dynamicbase.S -o test-dynamicbase.o

$ x86_64-w64-mingw32-ld --dynamicbase test-dynamicbase.o external.dll.a -o
test-dynamicbase.exe

$ x86_64-w64-mingw32-objdump -f -p test-dynamicbase.exe | grep -i reloc
HAS_RELOC, EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
Entry 5 0000000000000000 00000000 Base Relocation Directory [.reloc]

As can be seen in objdump output, binary is marked with HAS_RELOC but .reloc
section is completely empty.

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

Reply via email to