mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-09 17:12:54 +00:00
elf/x86-64: Subtract __ImageBase for R_AMD64_IMAGEBASE
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.
This commit is contained in:
@@ -1,3 +1,18 @@
|
|||||||
|
2021-03-05 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2021-03-05 Craig Blackmore <craig.blackmore@embecosm.com>
|
2021-03-05 Craig Blackmore <craig.blackmore@embecosm.com>
|
||||||
Andrew Burgess <andrew.burgess@embecosm.com>
|
Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
|
|||||||
11
bfd/bfd.c
11
bfd/bfd.c
@@ -2808,3 +2808,14 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
|
|||||||
*ptr_size = size;
|
*ptr_size = size;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the linker information. */
|
||||||
|
|
||||||
|
struct bfd_link_info *
|
||||||
|
_bfd_get_link_info (bfd *abfd)
|
||||||
|
{
|
||||||
|
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return elf_link_info (abfd);
|
||||||
|
}
|
||||||
|
|||||||
@@ -131,11 +131,38 @@ coff_amd64_reloc (bfd *abfd,
|
|||||||
diff -= reloc_entry->howto->type - R_AMD64_PCRLONG;
|
diff -= reloc_entry->howto->type - R_AMD64_PCRLONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: How should this case be handled? */
|
|
||||||
if (reloc_entry->howto->type == R_AMD64_IMAGEBASE
|
if (reloc_entry->howto->type == R_AMD64_IMAGEBASE
|
||||||
&& output_bfd != NULL
|
&& output_bfd == NULL)
|
||||||
&& bfd_get_flavour (output_bfd) == bfd_target_coff_flavour)
|
{
|
||||||
diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
|
bfd *obfd = input_section->output_section->owner;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
struct bfd_link_hash_entry *h;
|
||||||
|
switch (bfd_get_flavour (obfd))
|
||||||
|
{
|
||||||
|
case bfd_target_coff_flavour:
|
||||||
|
diff -= pe_data (obfd)->pe_opthdr.ImageBase;
|
||||||
|
break;
|
||||||
|
case bfd_target_elf_flavour:
|
||||||
|
/* Subtract __ImageBase. */
|
||||||
|
link_info = _bfd_get_link_info (obfd);
|
||||||
|
if (link_info == NULL)
|
||||||
|
return bfd_reloc_dangerous;
|
||||||
|
h = bfd_link_hash_lookup (link_info->hash, "__ImageBase",
|
||||||
|
FALSE, FALSE, FALSE);
|
||||||
|
if (h == NULL)
|
||||||
|
return bfd_reloc_dangerous;
|
||||||
|
while (h->type == bfd_link_hash_indirect)
|
||||||
|
h = h->u.i.link;
|
||||||
|
/* ELF symbols in relocatable files are section relative,
|
||||||
|
but in nonrelocatable files they are virtual addresses. */
|
||||||
|
diff -= (h->u.def.value
|
||||||
|
+ h->u.def.section->output_offset
|
||||||
|
+ h->u.def.section->output_section->vma);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DOIT(x) \
|
#define DOIT(x) \
|
||||||
|
|||||||
@@ -1887,6 +1887,9 @@ struct output_elf_obj_tdata
|
|||||||
/* Used when laying out sections. */
|
/* Used when laying out sections. */
|
||||||
file_ptr next_file_pos;
|
file_ptr next_file_pos;
|
||||||
|
|
||||||
|
/* Linker information. */
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
|
||||||
int num_section_syms;
|
int num_section_syms;
|
||||||
unsigned int shstrtab_section, strtab_section;
|
unsigned int shstrtab_section, strtab_section;
|
||||||
|
|
||||||
@@ -2064,6 +2067,7 @@ struct elf_obj_tdata
|
|||||||
#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
|
#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
|
||||||
#define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
|
#define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
|
||||||
#define elf_seg_map(bfd) (elf_tdata(bfd) -> o->seg_map)
|
#define elf_seg_map(bfd) (elf_tdata(bfd) -> o->seg_map)
|
||||||
|
#define elf_link_info(bfd) (elf_tdata(bfd) -> o->link_info)
|
||||||
#define elf_next_file_pos(bfd) (elf_tdata(bfd) -> o->next_file_pos)
|
#define elf_next_file_pos(bfd) (elf_tdata(bfd) -> o->next_file_pos)
|
||||||
#define elf_eh_frame_hdr(bfd) (elf_tdata(bfd) -> o->eh_frame_hdr)
|
#define elf_eh_frame_hdr(bfd) (elf_tdata(bfd) -> o->eh_frame_hdr)
|
||||||
#define elf_stack_flags(bfd) (elf_tdata(bfd) -> o->stack_flags)
|
#define elf_stack_flags(bfd) (elf_tdata(bfd) -> o->stack_flags)
|
||||||
|
|||||||
@@ -899,6 +899,8 @@ extern bfd_vma _bfd_safe_read_leb128
|
|||||||
extern bfd_byte * _bfd_write_unsigned_leb128
|
extern bfd_byte * _bfd_write_unsigned_leb128
|
||||||
(bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
|
(bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
|
||||||
|
|
||||||
|
extern struct bfd_link_info *_bfd_get_link_info (bfd *);
|
||||||
|
|
||||||
#if GCC_VERSION >= 7000
|
#if GCC_VERSION >= 7000
|
||||||
#define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
|
#define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -904,6 +904,8 @@ extern bfd_vma _bfd_safe_read_leb128
|
|||||||
extern bfd_byte * _bfd_write_unsigned_leb128
|
extern bfd_byte * _bfd_write_unsigned_leb128
|
||||||
(bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
|
(bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
|
||||||
|
|
||||||
|
extern struct bfd_link_info *_bfd_get_link_info (bfd *);
|
||||||
|
|
||||||
#if GCC_VERSION >= 7000
|
#if GCC_VERSION >= 7000
|
||||||
#define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
|
#define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
#define TARGET_SYM x86_64_pe_vec
|
#define TARGET_SYM x86_64_pe_vec
|
||||||
#define TARGET_NAME "pe-x86-64"
|
#define TARGET_NAME "pe-x86-64"
|
||||||
@@ -66,5 +68,33 @@ extern bfd_boolean pex64_bfd_print_pdata (bfd *, void *);
|
|||||||
|
|
||||||
#define bfd_pe_print_pdata pex64_bfd_print_pdata
|
#define bfd_pe_print_pdata pex64_bfd_print_pdata
|
||||||
|
|
||||||
#include "coff-x86_64.c"
|
static bfd_boolean
|
||||||
|
pex64_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
|
||||||
|
{
|
||||||
|
if (bfd_link_pde (info)
|
||||||
|
&& bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
|
||||||
|
{
|
||||||
|
/* NB: When linking Windows x86-64 relocatable object files to
|
||||||
|
generate ELF executable, create an indirect reference to
|
||||||
|
__executable_start for __ImageBase to support R_AMD64_IMAGEBASE
|
||||||
|
relocation which is relative to __ImageBase. */
|
||||||
|
struct bfd_link_hash_entry *h, *hi;
|
||||||
|
hi = bfd_link_hash_lookup (info->hash, "__ImageBase", TRUE, FALSE,
|
||||||
|
FALSE);
|
||||||
|
if (hi->type == bfd_link_hash_new
|
||||||
|
|| hi->type == bfd_link_hash_undefined
|
||||||
|
|| hi->type == bfd_link_hash_undefweak)
|
||||||
|
{
|
||||||
|
h = bfd_link_hash_lookup (info->hash, "__executable_start",
|
||||||
|
TRUE, FALSE, TRUE);
|
||||||
|
hi->type = bfd_link_hash_indirect;
|
||||||
|
hi->u.i.link = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _bfd_coff_link_add_symbols (abfd, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_bfd_link_add_symbols pex64_link_add_symbols
|
||||||
|
|
||||||
|
#include "coff-x86_64.c"
|
||||||
|
|||||||
18
ld/ChangeLog
18
ld/ChangeLog
@@ -1,3 +1,21 @@
|
|||||||
|
2021-03-05 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2021-03-04 Jan Beulich <jbeulich@suse.com>
|
2021-03-04 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
* testsuite/ld-scripts/map-address.exp: Set image base to zero
|
* testsuite/ld-scripts/map-address.exp: Set image base to zero
|
||||||
|
|||||||
@@ -919,7 +919,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
|
|||||||
${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
|
${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
|
||||||
${LDEMUL_BEFORE_PLACE_ORPHANS-ldelf_before_place_orphans},
|
${LDEMUL_BEFORE_PLACE_ORPHANS-ldelf_before_place_orphans},
|
||||||
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
|
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
|
||||||
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
|
${LDEMUL_SET_OUTPUT_ARCH-ldelf_set_output_arch},
|
||||||
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
|
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
|
||||||
${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
|
${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
|
||||||
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
|
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
|
||||||
|
|||||||
@@ -2206,3 +2206,11 @@ ldelf_before_place_orphans (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ldelf_set_output_arch (void)
|
||||||
|
{
|
||||||
|
set_output_arch_default ();
|
||||||
|
if (link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour)
|
||||||
|
elf_link_info (link_info.output_bfd) = &link_info;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,3 +31,4 @@ extern bfd_boolean ldelf_open_dynamic_archive
|
|||||||
extern lang_output_section_statement_type *ldelf_place_orphan
|
extern lang_output_section_statement_type *ldelf_place_orphan
|
||||||
(asection *, const char *, int);
|
(asection *, const char *, int);
|
||||||
extern void ldelf_before_place_orphans (void);
|
extern void ldelf_before_place_orphans (void);
|
||||||
|
extern void ldelf_set_output_arch (void);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.*: +file format .*
|
.*: +file format .*
|
||||||
|
|
||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
0+401000 g .text\$mn 0000000000000000 getaddr1
|
0+401000 g .text\$mn 0000000000000000 getaddr1
|
||||||
0+401020 g .text\$mn 0000000000000000 begin
|
0+401020 g .text\$mn 0000000000000000 begin
|
||||||
0+403014 g .bss 0000000000000000 __bss_start
|
0+403014 g .bss 0000000000000000 __bss_start
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.*: +file format .*
|
.*: +file format .*
|
||||||
|
|
||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
0+401000 g .text\$mn 0000000000000000 getaddr1
|
0+401000 g .text\$mn 0000000000000000 getaddr1
|
||||||
0+401020 g .text\$mn 0000000000000000 begin
|
0+401020 g .text\$mn 0000000000000000 begin
|
||||||
0+403014 g .bss 0000000000000000 __bss_start
|
0+403014 g .bss 0000000000000000 __bss_start
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.*: +file format .*
|
.*: +file format .*
|
||||||
|
|
||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
0+401000 g .text\$mn 0000000000000000 getaddr1
|
0+401000 g .text\$mn 0000000000000000 getaddr1
|
||||||
0+401020 g .text\$mn 0000000000000000 begin
|
0+401020 g .text\$mn 0000000000000000 begin
|
||||||
0+403014 g .bss 0000000000000000 __bss_start
|
0+403014 g .bss 0000000000000000 __bss_start
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.*: +file format .*
|
.*: +file format .*
|
||||||
|
|
||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
0+403038 g .bss 0000000000000000 c
|
0+403038 g .bss 0000000000000000 c
|
||||||
0+401000 g .text\$mn 0000000000000000 begin
|
0+401000 g .text\$mn 0000000000000000 begin
|
||||||
0+403038 g .bss 0000000000000000 __bss_start
|
0+403038 g .bss 0000000000000000 __bss_start
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
0+402014 g .bss 0000000000000000 non_initdummy
|
0+402014 g .bss 0000000000000000 non_initdummy
|
||||||
0+402010 g .data 0000000000000000 initdummy
|
0+402010 g .data 0000000000000000 initdummy
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
0+401000 g .text\$mn 0000000000000000 begin
|
0+401000 g .text\$mn 0000000000000000 begin
|
||||||
0+402012 g .bss 0000000000000000 __bss_start
|
0+402012 g .bss 0000000000000000 __bss_start
|
||||||
0+402000 g .data 0000000000000000 Struct
|
0+402000 g .data 0000000000000000 Struct
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
Symbol table '.symtab' contains 10 entries:
|
Symbol table '.symtab' contains 11 entries:
|
||||||
Num: Value Size Type Bind Vis Ndx Name
|
Num: Value Size Type Bind Vis Ndx Name
|
||||||
+[a-f0-9]+: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
+[a-f0-9]+: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
||||||
+[a-f0-9]+: 0000000000402014 0 NOTYPE GLOBAL DEFAULT 3 non_initdummy
|
+[a-f0-9]+: 0000000000402014 0 NOTYPE GLOBAL DEFAULT 3 non_initdummy
|
||||||
+[a-f0-9]+: 0000000000402010 0 NOTYPE GLOBAL DEFAULT 2 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]+: 0000000000401000 0 NOTYPE GLOBAL DEFAULT 1 begin
|
||||||
+[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 3 __bss_start
|
+[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 3 __bss_start
|
||||||
+[a-f0-9]+: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 Struct
|
+[a-f0-9]+: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 Struct
|
||||||
|
|||||||
BIN
ld/testsuite/ld-x86-64/pe-x86-64-6.obj.bz2
Normal file
BIN
ld/testsuite/ld-x86-64/pe-x86-64-6.obj.bz2
Normal file
Binary file not shown.
91
ld/testsuite/ld-x86-64/pe-x86-64-6.od
Normal file
91
ld/testsuite/ld-x86-64/pe-x86-64-6.od
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
.*: +file format .*
|
||||||
|
|
||||||
|
SYMBOL TABLE:
|
||||||
|
0+4010a8 g .text\$mn 0000000000000000 xfunc
|
||||||
|
0+402000 g .rdata 0000000000000000 \?\?_C@_02LDKJOMJN@AB@
|
||||||
|
0+400000 g .text\$mn 0000000000000000 __executable_start
|
||||||
|
0+403058 g .data 0000000000000000 __bss_start
|
||||||
|
0+401000 g .text\$mn 0000000000000000 main
|
||||||
|
0+403038 g .data 0000000000000000 deadloopvar
|
||||||
|
0+4010ac g .text\$mn 0000000000000000 xstring
|
||||||
|
0+403058 g .data 0000000000000000 _edata
|
||||||
|
0+403058 g .data 0000000000000000 _end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Disassembly of section .text\$mn:
|
||||||
|
|
||||||
|
0+401000 <main>:
|
||||||
|
+[a-f0-9]+: 48 89 5c 24 08 mov %rbx,0x8\(%rsp\)
|
||||||
|
+[a-f0-9]+: 48 89 6c 24 10 mov %rbp,0x10\(%rsp\)
|
||||||
|
+[a-f0-9]+: 48 89 74 24 20 mov %rsi,0x20\(%rsp\)
|
||||||
|
+[a-f0-9]+: 57 push %rdi
|
||||||
|
+[a-f0-9]+: 48 83 ec 20 sub \$0x20,%rsp
|
||||||
|
+[a-f0-9]+: cc int3
|
||||||
|
+[a-f0-9]+: 8b 05 1d 20 00 00 mov 0x201d\(%rip\),%eax # 403038 <deadloopvar>
|
||||||
|
+[a-f0-9]+: 83 f8 01 cmp \$0x1,%eax
|
||||||
|
+[a-f0-9]+: 74 f5 je 401015 <main\+0x15>
|
||||||
|
+[a-f0-9]+: 0f 31 rdtsc
|
||||||
|
+[a-f0-9]+: 48 c1 e2 20 shl \$0x20,%rdx
|
||||||
|
+[a-f0-9]+: 48 0b c2 or %rdx,%rax
|
||||||
|
+[a-f0-9]+: 74 5d je 401088 <main\+0x88>
|
||||||
|
+[a-f0-9]+: 33 ff xor %edi,%edi
|
||||||
|
+[a-f0-9]+: 48 8d 2d cc ef ff ff lea -0x1034\(%rip\),%rbp # 400000 <__executable_start>
|
||||||
|
+[a-f0-9]+: 33 db xor %ebx,%ebx
|
||||||
|
+[a-f0-9]+: 48 8d 35 ff 1f 00 00 lea 0x1fff\(%rip\),%rsi # 40303c <deadloopvar\+0x4>
|
||||||
|
+[a-f0-9]+: 48 8b 8c 2b 50 30 00 00 mov 0x3050\(%rbx,%rbp,1\),%rcx
|
||||||
|
+[a-f0-9]+: 44 8a 01 mov \(%rcx\),%r8b
|
||||||
|
+[a-f0-9]+: 45 84 c0 test %r8b,%r8b
|
||||||
|
+[a-f0-9]+: 74 28 je 401075 <main\+0x75>
|
||||||
|
+[a-f0-9]+: b8 05 00 00 00 mov \$0x5,%eax
|
||||||
|
+[a-f0-9]+: 2b 84 2b 48 30 00 00 sub 0x3048\(%rbx,%rbp,1\),%eax
|
||||||
|
+[a-f0-9]+: 99 cltd
|
||||||
|
+[a-f0-9]+: 2b c2 sub %edx,%eax
|
||||||
|
+[a-f0-9]+: d1 f8 sar %eax
|
||||||
|
+[a-f0-9]+: 48 63 d0 movslq %eax,%rdx
|
||||||
|
+[a-f0-9]+: 48 03 d6 add %rsi,%rdx
|
||||||
|
+[a-f0-9]+: 48 ff c1 inc %rcx
|
||||||
|
+[a-f0-9]+: 44 88 02 mov %r8b,\(%rdx\)
|
||||||
|
+[a-f0-9]+: 48 ff c2 inc %rdx
|
||||||
|
+[a-f0-9]+: 44 8a 01 mov \(%rcx\),%r8b
|
||||||
|
+[a-f0-9]+: 45 84 c0 test %r8b,%r8b
|
||||||
|
+[a-f0-9]+: 75 ef jne 401064 <main\+0x64>
|
||||||
|
+[a-f0-9]+: 48 8b ce mov %rsi,%rcx
|
||||||
|
+[a-f0-9]+: e8 2f 00 00 00 call 4010ac <xstring>
|
||||||
|
+[a-f0-9]+: ff c7 inc %edi
|
||||||
|
+[a-f0-9]+: 48 83 c3 08 add \$0x8,%rbx
|
||||||
|
+[a-f0-9]+: 83 ff 01 cmp \$0x1,%edi
|
||||||
|
+[a-f0-9]+: 72 b5 jb 40103d <main\+0x3d>
|
||||||
|
+[a-f0-9]+: b1 aa mov \$0xaa,%cl
|
||||||
|
+[a-f0-9]+: e8 19 00 00 00 call 4010a8 <xfunc>
|
||||||
|
+[a-f0-9]+: 48 8b 5c 24 30 mov 0x30\(%rsp\),%rbx
|
||||||
|
+[a-f0-9]+: 33 c0 xor %eax,%eax
|
||||||
|
+[a-f0-9]+: 48 8b 6c 24 38 mov 0x38\(%rsp\),%rbp
|
||||||
|
+[a-f0-9]+: 48 8b 74 24 48 mov 0x48\(%rsp\),%rsi
|
||||||
|
+[a-f0-9]+: 48 83 c4 20 add \$0x20,%rsp
|
||||||
|
+[a-f0-9]+: 5f pop %rdi
|
||||||
|
+[a-f0-9]+: c3 ret
|
||||||
|
+[a-f0-9]+: 66 90 xchg %ax,%ax
|
||||||
|
|
||||||
|
0+4010a8 <xfunc>:
|
||||||
|
+[a-f0-9]+: 66 90 xchg %ax,%ax
|
||||||
|
+[a-f0-9]+: cc int3
|
||||||
|
+[a-f0-9]+: c3 ret
|
||||||
|
|
||||||
|
0+4010ac <xstring>:
|
||||||
|
+[a-f0-9]+: 40 53 rex push %rbx
|
||||||
|
+[a-f0-9]+: 48 83 ec 20 sub \$0x20,%rsp
|
||||||
|
+[a-f0-9]+: 8a 01 mov \(%rcx\),%al
|
||||||
|
+[a-f0-9]+: 48 8b d9 mov %rcx,%rbx
|
||||||
|
+[a-f0-9]+: eb 0c jmp 4010c5 <xstring\+0x19>
|
||||||
|
+[a-f0-9]+: 8a c8 mov %al,%cl
|
||||||
|
+[a-f0-9]+: e8 e8 ff ff ff call 4010a8 <xfunc>
|
||||||
|
+[a-f0-9]+: 48 ff c3 inc %rbx
|
||||||
|
+[a-f0-9]+: 8a 03 mov \(%rbx\),%al
|
||||||
|
+[a-f0-9]+: 84 c0 test %al,%al
|
||||||
|
+[a-f0-9]+: 75 f0 jne 4010b9 <xstring\+0xd>
|
||||||
|
+[a-f0-9]+: 48 83 c4 20 add \$0x20,%rsp
|
||||||
|
+[a-f0-9]+: 5b pop %rbx
|
||||||
|
+[a-f0-9]+: c3 ret
|
||||||
|
#pass
|
||||||
@@ -73,4 +73,13 @@ run_ld_link_tests [list \
|
|||||||
{readelf {-s -x .data} pe-x86-64-5.rd}} \
|
{readelf {-s -x .data} pe-x86-64-5.rd}} \
|
||||||
"pe-x86-64-5" \
|
"pe-x86-64-5" \
|
||||||
] \
|
] \
|
||||||
|
[list \
|
||||||
|
"Build pe-x86-64-6" \
|
||||||
|
"-m elf_x86_64 --entry=main" \
|
||||||
|
"" \
|
||||||
|
"" \
|
||||||
|
{pe-x86-64-6.obj.bz2 } \
|
||||||
|
{{objdump {-dw --sym} pe-x86-64-6.od}} \
|
||||||
|
"pe-x86-64-6" \
|
||||||
|
] \
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user