mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
8c0546e928
When linking Windows x86-64 relocatable object files to generate x86-64 ELF executable, we need to subtract __ImageBase, aka __executable_start, for R_AMD64_IMAGEBASE relocation: 1. Add link_info to struct output_elf_obj_tdata to store linker info and _bfd_get_link_info() to retrieve it. 2. Add ldelf_set_output_arch to set up link_info. 3. Add pex64_link_add_symbols to create an indirect reference to __executable_start for __ImageBase to support R_AMD64_IMAGEBASE relocation when adding symbols from Windows x86-64 relocatable object files to generate x86-64 ELF executable. 4. Also subtract __ImageBase for R_AMD64_IMAGEBASE when generating x86-64 ELF executable. bfd/ PR ld/27425 PR ld/27432 * bfd.c (_bfd_get_link_info): New function. * elf-bfd.h (output_elf_obj_tdata): Add link_info. (elf_link_info): New. * libbfd-in.h (_bfd_get_link_info): New prototype. * coff-x86_64.c (coff_amd64_reloc): Also subtract __ImageBase for R_AMD64_IMAGEBASE when generating x86-64 ELF executable. * pe-x86_64.c: Include "coff/internal.h" and "libcoff.h". (pex64_link_add_symbols): New function. (coff_bfd_link_add_symbols): New macro. * libbfd.h: Regenerated. ld/ PR ld/27425 PR ld/27432 * ldelf.c (ldelf_set_output_arch): New function. * ldelf.h (ldelf_set_output_arch): New prototype. * emultempl/elf.em (LDEMUL_SET_OUTPUT_ARCH): Default to ldelf_set_output_arch. * ld-x86-64/pe-x86-64-1.od: Expect __executable_start. * testsuite/ld-x86-64/pe-x86-64-2.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-3.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-4.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-5.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-5.rd: Likewise. * testsuite/ld-x86-64/pe-x86-64-6.obj.bz2: New file. * testsuite/ld-x86-64/pe-x86-64-6.od: Likewise. * testsuite/ld-x86-64/pe-x86-64.exp: Run ld/27425 test.
21 lines
1.1 KiB
R
21 lines
1.1 KiB
R
|
|
Symbol table '.symtab' contains 11 entries:
|
|
Num: Value Size Type Bind Vis Ndx Name
|
|
+[a-f0-9]+: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
|
+[a-f0-9]+: 0000000000402014 0 NOTYPE GLOBAL DEFAULT 3 non_initdummy
|
|
+[a-f0-9]+: 0000000000402010 0 NOTYPE GLOBAL DEFAULT 2 initdummy
|
|
+[a-f0-9]+: 0000000000400000 0 NOTYPE GLOBAL DEFAULT 1 __executable_start
|
|
+[a-f0-9]+: 0000000000401000 0 NOTYPE GLOBAL DEFAULT 1 begin
|
|
+[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 3 __bss_start
|
|
+[a-f0-9]+: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 Struct
|
|
+[a-f0-9]+: 0000000000402011 0 NOTYPE GLOBAL DEFAULT 2 initializedVar
|
|
+[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 2 _edata
|
|
+[a-f0-9]+: 0000000000402018 0 NOTYPE GLOBAL DEFAULT 3 _end
|
|
+[a-f0-9]+: 0000000000402015 0 NOTYPE GLOBAL DEFAULT 3 non_initialVar
|
|
|
|
Hex dump of section '.data':
|
|
0x00402000 11204000 00000000 15204000 00000000 . @...... @.....
|
|
0x00402010 aa55 .U
|
|
|
|
#pass
|