diff options
author | Jan Beulich <jbeulich@suse.com> | 2022-01-06 14:17:40 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2022-01-06 14:17:40 +0100 |
commit | 1ef3994a3740f657e9af9dc354962a2c093586df (patch) | |
tree | ad8ea8e3b78f0b79c6fed3313807005f643684dd /gas | |
parent | 1f927a4a28e1cda3ada934ea118f81e3707e3911 (diff) | |
download | gdb-1ef3994a3740f657e9af9dc354962a2c093586df.zip gdb-1ef3994a3740f657e9af9dc354962a2c093586df.tar.gz gdb-1ef3994a3740f657e9af9dc354962a2c093586df.tar.bz2 |
x86-64: restrict PC32 -> PLT32 conversion
Neither non-64-bit code nor uses with a non-zero offset from a symbol
should be converted to PLT32, as an eventual PLT entry would not express
what was requested.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-i386.c | 9 | ||||
-rw-r--r-- | gas/config/tc-i386.h | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 66a2e0f..387fa60 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -8857,6 +8857,8 @@ output_branch (void) off = 0; } + frag_now->tc_frag_data.code64 = flag_code == CODE_64BIT; + /* 1 possible extra opcode + 4 byte displacement go in var part. Pass reloc in fr_var. */ frag_var (rs_machine_dependent, 5, i.reloc[0], subtype, sym, off, p); @@ -8985,8 +8987,8 @@ output_jump (void) } #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) - if (size == 4 - && jump_reloc == NO_RELOC + if (flag_code == CODE_64BIT && size == 4 + && jump_reloc == NO_RELOC && i.op[0].disps->X_add_number == 0 && need_plt32_p (i.op[0].disps->X_add_symbol)) jump_reloc = BFD_RELOC_X86_64_PLT32; #endif @@ -12294,7 +12296,8 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) else if (size == 2) reloc_type = BFD_RELOC_16_PCREL; #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) - else if (need_plt32_p (fragP->fr_symbol)) + else if (fragP->tc_frag_data.code64 && fragP->fr_offset == 0 + && need_plt32_p (fragP->fr_symbol)) reloc_type = BFD_RELOC_X86_64_PLT32; #endif else diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 4d67ef5..603ae47 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -283,6 +283,7 @@ struct i386_tc_frag_data unsigned int mf_type : 3; unsigned int classified : 1; unsigned int branch_type : 3; + unsigned int code64 : 1; /* Only set by output_branch for now. */ }; /* We need to emit the right NOP pattern in .align frags. This is |