ld, gold: remove support for -z bndplt (MPX prefix)

bfd/ChangeLog:

	* elf-linker-x86.h (struct elf_linker_x86_params): Remove
	bndplt.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Ignore
        R_X86_64_PLT32_BND.
	(elf_x86_64_relocate_section): Similarly here.
	(elf_x86_64_link_setup_gnu_properties): Ignore bndplt.
	* elfxx-x86.c: Likewise.
	* elfxx-x86.h: Likewise.

gold/ChangeLog:

	* NEWS: Document -z bndplt.
	* options.h (class General_options): Remove bndplt option.
	* x86_64.cc (class Output_data_plt_x86_64_bnd): Remove.
	(Target_x86_64::do_make_data_plt): Do not use
	Output_data_plt_x86_64_bnd.
	(Target_x86_64::Scan::get_reference_flags): Likewise.
	(Target_x86_64::Scan::check_non_pic): Likewise.
	(Target_x86_64::Scan::local): Likewise.
	(Target_x86_64::Scan::global): Likewise.

ld/ChangeLog:

	* NEWS: Document -z bndplt.
	* emulparams/elf_x86_64.sh: Remove bndplt option.
	* ld.texi: Likewise.
	* testsuite/ld-x86-64/x86-64.exp:
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.s: Removed.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-plt-1.d: Removed.
	* testsuite/ld-x86-64/mpx.exp: Removed.
	* testsuite/ld-x86-64/mpx1.out: Removed.
	* testsuite/ld-x86-64/mpx1a.c: Removed.
	* testsuite/ld-x86-64/mpx1a.rd: Removed.
	* testsuite/ld-x86-64/mpx1b.c: Removed.
	* testsuite/ld-x86-64/mpx1c.c: Removed.
	* testsuite/ld-x86-64/mpx1c.rd: Removed.
	* testsuite/ld-x86-64/mpx2.out: Removed.
	* testsuite/ld-x86-64/mpx2a.c: Removed.
	* testsuite/ld-x86-64/mpx2a.rd: Removed.
	* testsuite/ld-x86-64/mpx2b.c: Removed.
	* testsuite/ld-x86-64/mpx2c.c: Removed.
	* testsuite/ld-x86-64/mpx2c.rd: Removed.
	* testsuite/ld-x86-64/mpx3.dd: Removed.
	* testsuite/ld-x86-64/mpx3a.s: Removed.
	* testsuite/ld-x86-64/mpx3b.s: Removed.
	* testsuite/ld-x86-64/mpx3n.dd: Removed.
	* testsuite/ld-x86-64/mpx4.dd: Removed.
	* testsuite/ld-x86-64/mpx4a.s: Removed.
	* testsuite/ld-x86-64/mpx4b.s: Removed.
	* testsuite/ld-x86-64/mpx4n.dd: Removed.
	* testsuite/ld-x86-64/pr20800a.S: Removed.
	* testsuite/ld-x86-64/pr20800b.S: Removed.
	* testsuite/ld-x86-64/pr21038a-now.d: Removed.
	* testsuite/ld-x86-64/pr21038a.d: Removed.
	* testsuite/ld-x86-64/pr21038a.s: Removed.
	* testsuite/ld-x86-64/pr21038b-now.d: Removed.
	* testsuite/ld-x86-64/pr21038b.d: Removed.
	* testsuite/ld-x86-64/pr21038b.s: Removed.
	* testsuite/ld-x86-64/pr21038c-now.d: Removed.
	* testsuite/ld-x86-64/pr21038c.d: Removed.
	* testsuite/ld-x86-64/pr21038c.s: Removed.
This commit is contained in:
Martin Liska 2022-12-08 09:12:13 +01:00
parent d0517d6e33
commit 8ad93045ed
54 changed files with 12 additions and 1853 deletions

View file

@ -31,9 +31,6 @@ enum elf_x86_prop_report
/* Used to pass x86-specific linker options from ld to bfd. */
struct elf_linker_x86_params
{
/* TRUE if BND prefix in PLT entries is always generated. */
unsigned int bndplt: 1;
/* TRUE if IBT-enabled PLT entries should be generated. */
unsigned int ibtplt: 1;

View file

@ -2197,7 +2197,6 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
break;
case R_X86_64_PLT32:
case R_X86_64_PLT32_BND:
/* This symbol requires a procedure linkage table entry. We
actually build the entry in adjust_dynamic_symbol,
because this might be a case of linking PIC code which is
@ -2256,7 +2255,6 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
case R_X86_64_PC8:
case R_X86_64_PC16:
case R_X86_64_PC32:
case R_X86_64_PC32_BND:
case R_X86_64_PC64:
case R_X86_64_64:
pointer:
@ -2289,8 +2287,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
}
}
}
else if (r_type != R_X86_64_PC32_BND
&& r_type != R_X86_64_PC64)
else if (r_type != R_X86_64_PC64)
{
/* At run-time, R_X86_64_64 can be resolved for both
x86-64 and x32. But R_X86_64_32 and R_X86_64_32S
@ -2905,10 +2902,8 @@ elf_x86_64_relocate_section (bfd *output_bfd,
}
/* FALLTHROUGH */
case R_X86_64_PC32:
case R_X86_64_PC32_BND:
case R_X86_64_PC64:
case R_X86_64_PLT32:
case R_X86_64_PLT32_BND:
goto do_relocation;
}
}
@ -3172,7 +3167,6 @@ elf_x86_64_relocate_section (bfd *output_bfd,
break;
case R_X86_64_PLT32:
case R_X86_64_PLT32_BND:
/* Relocation is to the entry for this symbol in the
procedure linkage table. */
@ -3227,7 +3221,6 @@ elf_x86_64_relocate_section (bfd *output_bfd,
case R_X86_64_PC8:
case R_X86_64_PC16:
case R_X86_64_PC32:
case R_X86_64_PC32_BND:
/* Don't complain about -fPIC if the symbol is undefined when
building executable unless it is unresolved weak symbol,
references a dynamic definition in PIE or -z nocopyreloc
@ -5317,16 +5310,9 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
htab = elf_x86_hash_table (info, bed->target_id);
if (!htab)
abort ();
if (htab->params->bndplt)
{
init_table.lazy_plt = &elf_x86_64_lazy_bnd_plt;
init_table.non_lazy_plt = &elf_x86_64_non_lazy_bnd_plt;
}
else
{
init_table.lazy_plt = &elf_x86_64_lazy_plt;
init_table.non_lazy_plt = &elf_x86_64_non_lazy_plt;
}
init_table.lazy_plt = &elf_x86_64_lazy_plt;
init_table.non_lazy_plt = &elf_x86_64_non_lazy_plt;
init_table.lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
init_table.non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;

View file

@ -4415,20 +4415,6 @@ _bfd_x86_elf_link_setup_gnu_properties
if (!bfd_set_section_alignment (sec, plt_alignment))
goto error_alignment;
}
else if (htab->params->bndplt && ABI_64_P (dynobj))
{
/* Create the second PLT for Intel MPX support. MPX
PLT is supported only in 64-bit mode and is needed
only for lazy binding. */
sec = bfd_make_section_anyway_with_flags (dynobj,
".plt.sec",
pltflags);
if (sec == NULL)
info->callbacks->einfo (_("%F%P: failed to create BND PLT section\n"));
if (!bfd_set_section_alignment (sec, non_lazy_plt_alignment))
goto error_alignment;
}
htab->plt_second = sec;
}
@ -4499,7 +4485,7 @@ _bfd_x86_elf_link_setup_gnu_properties
htab->plt_sframe = sec;
/* Second PLT is generated for Intel IBT / MPX Support + lazy plt. */
/* Second PLT is generated for Intel IBT + lazy plt. */
if (htab->plt_second != NULL)
{
sec = bfd_make_section_anyway_with_flags (dynobj,

View file

@ -36,7 +36,6 @@
((TYPE) == R_X86_64_PC8 \
|| (TYPE) == R_X86_64_PC16 \
|| (TYPE) == R_X86_64_PC32 \
|| (TYPE) == R_X86_64_PC32_BND \
|| (TYPE) == R_X86_64_PC64)
#define I386_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
#define X86_PCREL_TYPE_P(IS_X86_64, TYPE) \
@ -103,7 +102,6 @@
((TYPE) == R_X86_64_PC8 \
|| (TYPE) == R_X86_64_PC16 \
|| (TYPE) == R_X86_64_PC32 \
|| (TYPE) == R_X86_64_PC32_BND \
|| (TYPE) == R_X86_64_PC64)
/* This must be the same as sframe_get_hdr_size (sfh). For x86-64, this value

View file

@ -1,7 +1,10 @@
* gold and dwp now support zstd compressed debug sections.
* The new option --compress-debug-sections=zstd compresses debug sections with
zstd.
* Remove support for -z bndplt (MPX prefix instructions).
Changes in 1.16:
* Improve warning messages for relocations that refer to discarded sections.

View file

@ -1460,9 +1460,6 @@ class General_options
// The -z options.
DEFINE_bool(bndplt, options::DASH_Z, '\0', false,
N_("(x86-64 only) Generate a BND PLT for Intel MPX"),
N_("Generate a regular PLT"));
DEFINE_bool(combreloc, options::DASH_Z, '\0', true,
N_("Sort dynamic relocs"),
N_("Do not sort dynamic relocs"));

View file

@ -430,118 +430,6 @@ class Output_data_plt_x86_64_standard : public Output_data_plt_x86_64<size>
static const unsigned char plt_eh_frame_fde[plt_eh_frame_fde_size];
};
class Output_data_plt_x86_64_bnd : public Output_data_plt_x86_64<64>
{
public:
Output_data_plt_x86_64_bnd(Layout* layout,
Output_data_got<64, false>* got,
Output_data_got_plt_x86_64* got_plt,
Output_data_space* got_irelative)
: Output_data_plt_x86_64<64>(layout, plt_entry_size,
got, got_plt, got_irelative),
aplt_offset_(0)
{ }
Output_data_plt_x86_64_bnd(Layout* layout,
Output_data_got<64, false>* got,
Output_data_got_plt_x86_64* got_plt,
Output_data_space* got_irelative,
unsigned int plt_count)
: Output_data_plt_x86_64<64>(layout, plt_entry_size,
got, got_plt, got_irelative,
plt_count),
aplt_offset_(0)
{ }
protected:
virtual unsigned int
do_get_plt_entry_size() const
{ return plt_entry_size; }
// Return the PLT address to use for a global symbol.
uint64_t
do_address_for_global(const Symbol*);
// Return the PLT address to use for a local symbol.
uint64_t
do_address_for_local(const Relobj*, unsigned int symndx);
virtual void
do_add_eh_frame(Layout* layout)
{
layout->add_eh_frame_for_plt(this,
this->plt_eh_frame_cie,
this->plt_eh_frame_cie_size,
plt_eh_frame_fde,
plt_eh_frame_fde_size);
}
virtual void
do_fill_first_plt_entry(unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_addr,
elfcpp::Elf_types<64>::Elf_Addr plt_addr);
virtual unsigned int
do_fill_plt_entry(unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address,
unsigned int got_offset,
unsigned int plt_offset,
unsigned int plt_index);
virtual void
do_fill_tlsdesc_entry(unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address,
elfcpp::Elf_types<64>::Elf_Addr got_base,
unsigned int tlsdesc_got_offset,
unsigned int plt_offset);
void
fill_aplt_entry(unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address,
unsigned int got_offset,
unsigned int plt_offset,
unsigned int plt_index);
private:
// Set the final size.
void
set_final_data_size();
// Write out the BND PLT data.
void
do_write(Output_file*);
// Offset of the Additional PLT (if using -z bndplt).
unsigned int aplt_offset_;
// The size of an entry in the PLT.
static const int plt_entry_size = 16;
// The size of an entry in the additional PLT.
static const int aplt_entry_size = 8;
// The first entry in the PLT.
// From the AMD64 ABI: "Unlike Intel386 ABI, this ABI uses the same
// procedure linkage table for both programs and shared objects."
static const unsigned char first_plt_entry[plt_entry_size];
// Other entries in the PLT for an executable.
static const unsigned char plt_entry[plt_entry_size];
// Entries in the additional PLT.
static const unsigned char aplt_entry[aplt_entry_size];
// The reserved TLSDESC entry in the PLT for an executable.
static const unsigned char tlsdesc_plt_entry[plt_entry_size];
// The .eh_frame unwind information for the PLT.
static const int plt_eh_frame_fde_size = 32;
static const unsigned char plt_eh_frame_fde[plt_eh_frame_fde_size];
};
// We use this PLT when Indirect Branch Tracking (IBT) is enabled.
template <int size>
@ -625,7 +513,7 @@ class Output_data_plt_x86_64_ibt : public Output_data_plt_x86_64<size>
void
set_final_data_size();
// Write out the BND PLT data.
// Write out the PLT data.
void
do_write(Output_file*);
@ -2091,183 +1979,6 @@ Output_data_plt_x86_64_standard<size>::do_fill_tlsdesc_entry(
+ 12)));
}
// Return the APLT address to use for a global symbol (for -z bndplt).
uint64_t
Output_data_plt_x86_64_bnd::do_address_for_global(const Symbol* gsym)
{
uint64_t offset = this->aplt_offset_;
// Convert the PLT offset into an APLT offset.
unsigned int plt_offset = gsym->plt_offset();
if (gsym->type() == elfcpp::STT_GNU_IFUNC
&& gsym->can_use_relative_reloc(false))
offset += this->regular_count() * aplt_entry_size;
else
plt_offset -= plt_entry_size;
plt_offset = plt_offset / (plt_entry_size / aplt_entry_size);
return this->address() + offset + plt_offset;
}
// Return the PLT address to use for a local symbol. These are always
// IRELATIVE relocs.
uint64_t
Output_data_plt_x86_64_bnd::do_address_for_local(const Relobj* object,
unsigned int r_sym)
{
// Convert the PLT offset into an APLT offset.
const Sized_relobj_file<64, false>* sized_relobj =
static_cast<const Sized_relobj_file<64, false>*>(object);
const Symbol_value<64>* psymval = sized_relobj->local_symbol(r_sym);
unsigned int plt_offset = ((object->local_plt_offset(r_sym)
- (psymval->is_ifunc_symbol()
? 0 : plt_entry_size))
/ (plt_entry_size / aplt_entry_size));
return (this->address()
+ this->aplt_offset_
+ this->regular_count() * aplt_entry_size
+ plt_offset);
}
// Set the final size.
void
Output_data_plt_x86_64_bnd::set_final_data_size()
{
// Number of regular and IFUNC PLT entries.
unsigned int count = this->entry_count();
// Count the first entry and the TLSDESC entry, if present.
unsigned int extra = this->has_tlsdesc_entry() ? 2 : 1;
unsigned int plt_size = (count + extra) * plt_entry_size;
// Offset of the APLT.
this->aplt_offset_ = plt_size;
// Size of the APLT.
plt_size += count * aplt_entry_size;
this->set_data_size(plt_size);
}
// The first entry in the BND PLT.
const unsigned char
Output_data_plt_x86_64_bnd::first_plt_entry[plt_entry_size] =
{
// From AMD64 ABI Draft 0.98, page 76
0xff, 0x35, // pushq contents of memory address
0, 0, 0, 0, // replaced with address of .got + 8
0xf2, 0xff, 0x25, // bnd jmp indirect
0, 0, 0, 0, // replaced with address of .got + 16
0x0f, 0x1f, 0x00 // nop
};
void
Output_data_plt_x86_64_bnd::do_fill_first_plt_entry(
unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address)
{
memcpy(pov, first_plt_entry, plt_entry_size);
// We do a jmp relative to the PC at the end of this instruction.
elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + 6)));
elfcpp::Swap<32, false>::writeval(pov + 9,
(got_address + 16
- (plt_address + 13)));
}
// Subsequent entries in the BND PLT.
const unsigned char
Output_data_plt_x86_64_bnd::plt_entry[plt_entry_size] =
{
// From AMD64 ABI Draft 0.99.8, page 139
0x68, // pushq immediate
0, 0, 0, 0, // replaced with offset into relocation table
0xf2, 0xe9, // bnd jmpq relative
0, 0, 0, 0, // replaced with offset to start of .plt
0x0f, 0x1f, 0x44, 0, 0 // nop
};
// Entries in the BND Additional PLT.
const unsigned char
Output_data_plt_x86_64_bnd::aplt_entry[aplt_entry_size] =
{
// From AMD64 ABI Draft 0.99.8, page 139
0xf2, 0xff, 0x25, // bnd jmpq indirect
0, 0, 0, 0, // replaced with address of symbol in .got
0x90, // nop
};
unsigned int
Output_data_plt_x86_64_bnd::do_fill_plt_entry(
unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr,
elfcpp::Elf_types<64>::Elf_Addr,
unsigned int,
unsigned int plt_offset,
unsigned int plt_index)
{
memcpy(pov, plt_entry, plt_entry_size);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 1, plt_index);
elfcpp::Swap<32, false>::writeval(pov + 7, -(plt_offset + 11));
return 0;
}
void
Output_data_plt_x86_64_bnd::fill_aplt_entry(
unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address,
unsigned int got_offset,
unsigned int plt_offset,
unsigned int plt_index)
{
// Check PC-relative offset overflow in PLT entry.
uint64_t plt_got_pcrel_offset = (got_address + got_offset
- (plt_address + plt_offset + 7));
if (Bits<32>::has_overflow(plt_got_pcrel_offset))
gold_error(_("PC-relative offset overflow in APLT entry %d"),
plt_index + 1);
memcpy(pov, aplt_entry, aplt_entry_size);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 3, plt_got_pcrel_offset);
}
// The reserved TLSDESC entry in the PLT for an executable.
const unsigned char
Output_data_plt_x86_64_bnd::tlsdesc_plt_entry[plt_entry_size] =
{
// From Alexandre Oliva, "Thread-Local Storage Descriptors for IA32
// and AMD64/EM64T", Version 0.9.4 (2005-10-10).
0xff, 0x35, // pushq x(%rip)
0, 0, 0, 0, // replaced with address of linkmap GOT entry (at PLTGOT + 8)
0xf2, 0xff, 0x25, // jmpq *y(%rip)
0, 0, 0, 0, // replaced with offset of reserved TLSDESC_GOT entry
0x0f, 0x1f, 0 // nop
};
void
Output_data_plt_x86_64_bnd::do_fill_tlsdesc_entry(
unsigned char* pov,
elfcpp::Elf_types<64>::Elf_Addr got_address,
elfcpp::Elf_types<64>::Elf_Addr plt_address,
elfcpp::Elf_types<64>::Elf_Addr got_base,
unsigned int tlsdesc_got_offset,
unsigned int plt_offset)
{
memcpy(pov, tlsdesc_plt_entry, plt_entry_size);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + plt_offset
+ 6)));
elfcpp::Swap_unaligned<32, false>::writeval(pov + 9,
(got_base
+ tlsdesc_got_offset
- (plt_address + plt_offset
+ 13)));
}
// Return the APLT address to use for a global symbol (for IBT).
template<int size>
@ -2520,35 +2231,7 @@ Output_data_plt_x86_64_standard<size>::plt_eh_frame_fde[plt_eh_frame_fde_size] =
elfcpp::DW_CFA_nop
};
// The .eh_frame unwind information for the BND PLT.
const unsigned char
Output_data_plt_x86_64_bnd::plt_eh_frame_fde[plt_eh_frame_fde_size] =
{
0, 0, 0, 0, // Replaced with offset to .plt.
0, 0, 0, 0, // Replaced with size of .plt.
0, // Augmentation size.
elfcpp::DW_CFA_def_cfa_offset, 16, // DW_CFA_def_cfa_offset: 16.
elfcpp::DW_CFA_advance_loc + 6, // Advance 6 to __PLT__ + 6.
elfcpp::DW_CFA_def_cfa_offset, 24, // DW_CFA_def_cfa_offset: 24.
elfcpp::DW_CFA_advance_loc + 10, // Advance 10 to __PLT__ + 16.
elfcpp::DW_CFA_def_cfa_expression, // DW_CFA_def_cfa_expression.
11, // Block length.
elfcpp::DW_OP_breg7, 8, // Push %rsp + 8.
elfcpp::DW_OP_breg16, 0, // Push %rip.
elfcpp::DW_OP_lit15, // Push 0xf.
elfcpp::DW_OP_and, // & (%rip & 0xf).
elfcpp::DW_OP_lit5, // Push 5.
elfcpp::DW_OP_ge, // >= ((%rip & 0xf) >= 5)
elfcpp::DW_OP_lit3, // Push 3.
elfcpp::DW_OP_shl, // << (((%rip & 0xf) >= 5) << 3)
elfcpp::DW_OP_plus, // + ((((%rip&0xf)>=5)<<3)+%rsp+8
elfcpp::DW_CFA_nop, // Align to 32 bytes.
elfcpp::DW_CFA_nop,
elfcpp::DW_CFA_nop,
elfcpp::DW_CFA_nop
};
// The .eh_frame unwind information for the BND PLT.
// The .eh_frame unwind information for the PLT.
template<int size>
const unsigned char
Output_data_plt_x86_64_ibt<size>::plt_eh_frame_fde[plt_eh_frame_fde_size] =
@ -2656,101 +2339,6 @@ Output_data_plt_x86_64<size>::do_write(Output_file* of)
of->write_output_view(got_file_offset, got_size, got_view);
}
// Write out the BND PLT.
void
Output_data_plt_x86_64_bnd::do_write(Output_file* of)
{
const off_t offset = this->offset();
const section_size_type oview_size =
convert_to_section_size_type(this->data_size());
unsigned char* const oview = of->get_output_view(offset, oview_size);
Output_data_got<64, false>* got = this->got();
Output_data_got_plt_x86_64* got_plt = this->got_plt();
Output_data_space* got_irelative = this->got_irelative();
const off_t got_file_offset = got_plt->offset();
gold_assert(parameters->incremental_update()
|| (got_file_offset + got_plt->data_size()
== got_irelative->offset()));
const section_size_type got_size =
convert_to_section_size_type(got_plt->data_size()
+ got_irelative->data_size());
unsigned char* const got_view = of->get_output_view(got_file_offset,
got_size);
unsigned char* pov = oview;
// The base address of the .plt section.
elfcpp::Elf_types<64>::Elf_Addr plt_address = this->address();
// The base address of the .got section.
elfcpp::Elf_types<64>::Elf_Addr got_base = got->address();
// The base address of the PLT portion of the .got section,
// which is where the GOT pointer will point, and where the
// three reserved GOT entries are located.
elfcpp::Elf_types<64>::Elf_Addr got_address = got_plt->address();
this->fill_first_plt_entry(pov, got_address, plt_address);
pov += plt_entry_size;
// The first three entries in the GOT are reserved, and are written
// by Output_data_got_plt_x86_64::do_write.
unsigned char* got_pov = got_view + 24;
unsigned int plt_offset = plt_entry_size;
unsigned int got_offset = 24;
const unsigned int count = this->entry_count();
for (unsigned int plt_index = 0;
plt_index < count;
++plt_index,
pov += plt_entry_size,
got_pov += 8,
plt_offset += plt_entry_size,
got_offset += 8)
{
// Set and adjust the PLT entry itself.
unsigned int lazy_offset = this->fill_plt_entry(pov,
got_address, plt_address,
got_offset, plt_offset,
plt_index);
// Set the entry in the GOT.
elfcpp::Swap<64, false>::writeval(got_pov,
plt_address + plt_offset + lazy_offset);
}
if (this->has_tlsdesc_entry())
{
// Set and adjust the reserved TLSDESC PLT entry.
unsigned int tlsdesc_got_offset = this->get_tlsdesc_got_offset();
this->fill_tlsdesc_entry(pov, got_address, plt_address, got_base,
tlsdesc_got_offset, plt_offset);
pov += this->get_plt_entry_size();
plt_offset += plt_entry_size;
}
// Write the additional PLT.
got_offset = 24;
for (unsigned int plt_index = 0;
plt_index < count;
++plt_index,
pov += aplt_entry_size,
plt_offset += aplt_entry_size,
got_offset += 8)
{
// Set and adjust the APLT entry.
this->fill_aplt_entry(pov, got_address, plt_address, got_offset,
plt_offset, plt_index);
}
gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size);
of->write_output_view(offset, oview_size, oview);
of->write_output_view(got_file_offset, got_size, got_view);
}
// Write out the IBT PLT.
template<int size>
@ -2900,9 +2488,6 @@ Target_x86_64<64>::do_make_data_plt(Layout* layout,
if (this->feature_1_ & elfcpp::GNU_PROPERTY_X86_FEATURE_1_IBT)
return new Output_data_plt_x86_64_ibt<64>(layout, got, got_plt,
got_irelative);
else if (parameters->options().bndplt())
return new Output_data_plt_x86_64_bnd(layout, got, got_plt,
got_irelative);
else
return new Output_data_plt_x86_64_standard<64>(layout, got, got_plt,
got_irelative);
@ -2934,9 +2519,6 @@ Target_x86_64<64>::do_make_data_plt(Layout* layout,
if (this->feature_1_ & elfcpp::GNU_PROPERTY_X86_FEATURE_1_IBT)
return new Output_data_plt_x86_64_ibt<64>(layout, got, got_plt,
got_irelative, plt_count);
else if (parameters->options().bndplt())
return new Output_data_plt_x86_64_bnd(layout, got, got_plt,
got_irelative, plt_count);
else
return new Output_data_plt_x86_64_standard<64>(layout, got, got_plt,
got_irelative,
@ -3374,14 +2956,12 @@ Target_x86_64<size>::Scan::get_reference_flags(unsigned int r_type)
case elfcpp::R_X86_64_PC64:
case elfcpp::R_X86_64_PC32:
case elfcpp::R_X86_64_PC32_BND:
case elfcpp::R_X86_64_PC16:
case elfcpp::R_X86_64_PC8:
case elfcpp::R_X86_64_GOTOFF64:
return Symbol::RELATIVE_REF;
case elfcpp::R_X86_64_PLT32:
case elfcpp::R_X86_64_PLT32_BND:
case elfcpp::R_X86_64_PLTOFF64:
return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF;
@ -3465,7 +3045,6 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type,
// glibc supports these reloc types, but they can overflow.
case elfcpp::R_X86_64_PC32:
case elfcpp::R_X86_64_PC32_BND:
// A PC relative reference is OK against a local symbol or if
// the symbol is defined locally.
if (gsym == NULL
@ -3495,9 +3074,6 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type,
case elfcpp::R_X86_64_PC32:
r_name = "R_X86_64_PC32";
break;
case elfcpp::R_X86_64_PC32_BND:
r_name = "R_X86_64_PC32_BND";
break;
default:
gold_unreachable();
break;
@ -3650,13 +3226,11 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab,
case elfcpp::R_X86_64_PC64:
case elfcpp::R_X86_64_PC32:
case elfcpp::R_X86_64_PC32_BND:
case elfcpp::R_X86_64_PC16:
case elfcpp::R_X86_64_PC8:
break;
case elfcpp::R_X86_64_PLT32:
case elfcpp::R_X86_64_PLT32_BND:
// Since we know this is a local symbol, we can handle this as a
// PC32 reloc.
break;
@ -4107,7 +3681,6 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab,
case elfcpp::R_X86_64_PC64:
case elfcpp::R_X86_64_PC32:
case elfcpp::R_X86_64_PC32_BND:
case elfcpp::R_X86_64_PC16:
case elfcpp::R_X86_64_PC8:
{
@ -4240,7 +3813,6 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab,
break;
case elfcpp::R_X86_64_PLT32:
case elfcpp::R_X86_64_PLT32_BND:
// If the symbol is fully resolved, this is just a PC32 reloc.
// Otherwise we need a PLT entry.
if (gsym->final_value_is_known())
@ -4658,8 +4230,6 @@ Target_x86_64<size>::Relocate::relocate(
if ((r_type != elfcpp::R_X86_64_PLT32
&& r_type != elfcpp::R_X86_64_GOTPCREL
&& r_type != elfcpp::R_X86_64_GOTPCRELX
&& r_type != elfcpp::R_X86_64_PLT32_BND
&& r_type != elfcpp::R_X86_64_PC32_BND
&& r_type != elfcpp::R_X86_64_PC32)
|| gsym == NULL
|| strcmp(gsym->name(), "__tls_get_addr") != 0)
@ -4762,7 +4332,6 @@ Target_x86_64<size>::Relocate::relocate(
break;
case elfcpp::R_X86_64_PC32:
case elfcpp::R_X86_64_PC32_BND:
rstatus = Reloc_funcs::pcrela32_check(view, object, psymval, addend,
address);
break;
@ -4784,7 +4353,6 @@ Target_x86_64<size>::Relocate::relocate(
break;
case elfcpp::R_X86_64_PLT32:
case elfcpp::R_X86_64_PLT32_BND:
gold_assert(gsym == NULL
|| gsym->has_plt_offset()
|| gsym->final_value_is_known()

View file

@ -11,6 +11,8 @@
that selects the default compression algorithm
for --enable-compressed-debug-sections.
* Remove support for -z bndplt (MPX prefix instructions).
Changes in 2.39:
* The ELF linker will now generate a warning message if the stack is made

View file

@ -47,16 +47,6 @@ case "$target" in
case "$EMULATION_NAME" in
*64*)
LIBPATH_SUFFIX=64
PARSE_AND_LIST_OPTIONS_BNDPLT='
fprintf (file, _("\
-z bndplt Always generate BND prefix in PLT entries\n"));
'
PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT='
else if (strcmp (optarg, "bndplt") == 0)
params.bndplt = true;
'
PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_BNDPLT"
PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT"
;;
esac
;;

View file

@ -1208,9 +1208,6 @@ for Solaris compatibility.
The recognized keywords are:
@table @samp
@item bndplt
Always generate BND prefix in PLT entries. Supported for Linux/x86_64.
@item call-nop=prefix-addr
@itemx call-nop=suffix-nop
@itemx call-nop=prefix-@var{byte}

View file

@ -1,45 +0,0 @@
#source: bnd-branch-1.s -mx86-used-note=no
#as: --64
#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
Disassembly of section .plt:
0+230 <foo2@plt-0x10>:
+[a-f0-9]+: ff 35 82 01 20 00 push 0x200182\(%rip\) # 2003b8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: ff 25 84 01 20 00 jmp \*0x200184\(%rip\) # 2003c0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
0+240 <foo2@plt>:
+[a-f0-9]+: ff 25 82 01 20 00 jmp \*0x200182\(%rip\) # 2003c8 <foo2>
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: e9 e0 ff ff ff jmp 230 <foo2@plt-0x10>
0+250 <foo3@plt>:
+[a-f0-9]+: ff 25 7a 01 20 00 jmp \*0x20017a\(%rip\) # 2003d0 <foo3>
+[a-f0-9]+: 68 01 00 00 00 push \$0x1
+[a-f0-9]+: e9 d0 ff ff ff jmp 230 <foo2@plt-0x10>
0+260 <foo1@plt>:
+[a-f0-9]+: ff 25 72 01 20 00 jmp \*0x200172\(%rip\) # 2003d8 <foo1>
+[a-f0-9]+: 68 02 00 00 00 push \$0x2
+[a-f0-9]+: e9 c0 ff ff ff jmp 230 <foo2@plt-0x10>
0+270 <foo4@plt>:
+[a-f0-9]+: ff 25 6a 01 20 00 jmp \*0x20016a\(%rip\) # 2003e0 <foo4>
+[a-f0-9]+: 68 03 00 00 00 push \$0x3
+[a-f0-9]+: e9 b0 ff ff ff jmp 230 <foo2@plt-0x10>
Disassembly of section .text:
0+280 <_start>:
+[a-f0-9]+: f2 e9 da ff ff ff bnd jmp 260 <foo1@plt>
+[a-f0-9]+: e8 b5 ff ff ff call 240 <foo2@plt>
+[a-f0-9]+: e9 c0 ff ff ff jmp 250 <foo3@plt>
+[a-f0-9]+: e8 db ff ff ff call 270 <foo4@plt>
+[a-f0-9]+: f2 e8 b5 ff ff ff bnd call 250 <foo3@plt>
+[a-f0-9]+: e9 d0 ff ff ff jmp 270 <foo4@plt>
#pass

View file

@ -1,19 +0,0 @@
#as: --64
#ld: -shared -melf_x86_64
#objdump: -dw
.*: +file format .*
#...
Disassembly of section .text:
#...
[a-f0-9]+ <_start>:
[ ]*[a-f0-9]+: f2 e9 [a-f0-9]+ ff ff ff bnd jmp [a-f0-9]+ <foo1@plt>
[ ]*[a-f0-9]+: e8 [a-f0-9]+ ff ff ff call [a-f0-9]+ <foo2@plt>
[ ]*[a-f0-9]+: e9 [a-f0-9]+ ff ff ff jmp [a-f0-9]+ <foo3@plt>
[ ]*[a-f0-9]+: e8 [a-f0-9]+ ff ff ff call [a-f0-9]+ <foo4@plt>
[ ]*[a-f0-9]+: f2 e8 [a-f0-9]+ ff ff ff bnd call [a-f0-9]+ <foo3@plt>
[ ]*[a-f0-9]+: e9 [a-f0-9]+ ff ff ff jmp [a-f0-9]+ <foo4@plt>
#pass

View file

@ -1,9 +0,0 @@
.text
.globl _start
_start:
bnd jmp foo1@plt
call foo2@plt
jmp foo3@plt
call foo4@plt
bnd call foo3@plt
jmp foo4@plt

View file

@ -1,33 +0,0 @@
#source: bnd-ifunc-1.s
#as: --64 -madd-bnd-prefix -mx86-used-note=no
#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
Disassembly of section .plt:
0+170 <.plt>:
+[a-f0-9]+: ff 35 4a 01 20 00 push 0x20014a\(%rip\) # 2002c0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 4b 01 20 00 bnd jmp \*0x20014b\(%rip\) # 2002c8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 170 <\*ABS\*\+0x198@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+190 <\*ABS\*\+0x198@plt>:
+[a-f0-9]+: f2 ff 25 39 01 20 00 bnd jmp \*0x200139\(%rip\) # 2002d0 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+198 <foo>:
+[a-f0-9]+: f2 c3 bnd ret
0+19a <bar>:
+[a-f0-9]+: f2 e8 f0 ff ff ff bnd call 190 <\*ABS\*\+0x198@plt>
+[a-f0-9]+: f2 c3 bnd ret
#pass

View file

@ -1,7 +0,0 @@
#as: --64 -madd-bnd-prefix
#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv
#objdump: -dw
#...
[ ]*[a-f0-9]+: f2 e8 f0 ff ff ff bnd call [a-f0-9]+ <\*ABS\*\+0x[a-f0-9]+@plt>
#pass

View file

@ -1,16 +0,0 @@
.type foo, %gnu_indirect_function
.global __GI_foo
.hidden __GI_foo
.set __GI_foo, foo
.text
.globl foo
.type foo, @function
foo:
ret
.size foo, .-foo
.globl bar
.type bar, @function
bar:
call __GI_foo@PLT
ret
.size bar, .-bar

View file

@ -1,59 +0,0 @@
#source: bnd-ifunc-2.s
#as: --64 -madd-bnd-prefix -mx86-used-note=no
#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
Disassembly of section .plt:
0+240 <.plt>:
+[a-f0-9]+: ff 35 9a 01 20 00 push 0x20019a\(%rip\) # 2003e0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 9b 01 20 00 bnd jmp \*0x20019b\(%rip\) # 2003e8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 03 00 00 00 push \$0x3
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 d5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 01 00 00 00 push \$0x1
+[a-f0-9]+: f2 e9 c5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 02 00 00 00 push \$0x2
+[a-f0-9]+: f2 e9 b5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+290 <\*ABS\*\+0x2bc@plt>:
+[a-f0-9]+: f2 ff 25 59 01 20 00 bnd jmp \*0x200159\(%rip\) # 2003f0 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[a-f0-9]+: 90 nop
0+298 <func1@plt>:
+[a-f0-9]+: f2 ff 25 59 01 20 00 bnd jmp \*0x200159\(%rip\) # 2003f8 <func1>
+[a-f0-9]+: 90 nop
0+2a0 <func2@plt>:
+[a-f0-9]+: f2 ff 25 59 01 20 00 bnd jmp \*0x200159\(%rip\) # 200400 <func2>
+[a-f0-9]+: 90 nop
0+2a8 <\*ABS\*\+0x2b0@plt>:
+[a-f0-9]+: f2 ff 25 59 01 20 00 bnd jmp \*0x200159\(%rip\) # 200408 <_GLOBAL_OFFSET_TABLE_\+0x30>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+2b0 <resolve1>:
+[a-f0-9]+: f2 e8 e2 ff ff ff bnd call 298 <func1@plt>
0+2b6 <g1>:
+[a-f0-9]+: f2 e9 ec ff ff ff bnd jmp 2a8 <\*ABS\*\+0x2b0@plt>
0+2bc <resolve2>:
+[a-f0-9]+: f2 e8 de ff ff ff bnd call 2a0 <func2@plt>
0+2c2 <g2>:
+[a-f0-9]+: f2 e9 c8 ff ff ff bnd jmp 290 <\*ABS\*\+0x2bc@plt>
#pass

View file

@ -1,54 +0,0 @@
#as: --64 -madd-bnd-prefix -mx86-used-note=no
#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#...
0+240 <.plt>:
[ ]*[a-f0-9]+: ff 35 7a 01 20 00 push 0x20017a\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: f2 ff 25 7b 01 20 00 bnd jmp \*0x20017b\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
[ ]*[a-f0-9]+: 68 03 00 00 00 push \$0x3
[ ]*[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0
[ ]*[a-f0-9]+: f2 e9 d5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 01 00 00 00 push \$0x1
[ ]*[a-f0-9]+: f2 e9 c5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 02 00 00 00 push \$0x2
[ ]*[a-f0-9]+: f2 e9 b5 ff ff ff bnd jmp 240 <\*ABS\*\+0x2bc@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+290 <\*ABS\*\+0x2bc@plt>:
[ ]*[a-f0-9]+: f2 ff 25 39 01 20 00 bnd jmp \*0x200139\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+298 <func1@plt>:
[ ]*[a-f0-9]+: f2 ff 25 39 01 20 00 bnd jmp \*0x200139\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+2a0 <func2@plt>:
[ ]*[a-f0-9]+: f2 ff 25 39 01 20 00 bnd jmp \*0x200139\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+2a8 <\*ABS\*\+0x2b0@plt>:
[ ]*[a-f0-9]+: f2 ff 25 39 01 20 00 bnd jmp \*0x200139\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
Disassembly of section .text:
0+2b0 <resolve1>:
[ ]*[a-f0-9]+: f2 e8 e2 ff ff ff bnd call 298 <func1@plt>
0+2b6 <g1>:
[ ]*[a-f0-9]+: f2 e9 ec ff ff ff bnd jmp 2a8 <\*ABS\*\+0x2b0@plt>
0+2bc <resolve2>:
[ ]*[a-f0-9]+: f2 e8 de ff ff ff bnd call 2a0 <func2@plt>
0+2c2 <g2>:
[ ]*[a-f0-9]+: f2 e9 c8 ff ff ff bnd jmp 290 <\*ABS\*\+0x2bc@plt>
#pass

View file

@ -1,28 +0,0 @@
.text
.globl fct1
.type fct1, @gnu_indirect_function
.set fct1,resolve1
.hidden int_fct1
.globl int_fct1
.set int_fct1,fct1
.type resolve1, @function
resolve1:
call func1@PLT
.globl g1
.type g1, @function
g1:
jmp int_fct1@PLT
.globl fct2
.type fct2, @gnu_indirect_function
.set fct2,resolve2
.hidden int_fct2
.globl int_fct2
.set int_fct2,fct2
.type resolve2, @function
resolve2:
call func2@PLT
.globl g2
.type g2, @function
g2:
jmp int_fct2@PLT

View file

@ -1,55 +0,0 @@
#source: bnd-branch-1.s
#as: --64 -mx86-used-note=no
#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
Disassembly of section .plt:
0+230 <.plt>:
+[a-f0-9]+: ff 35 a2 01 20 00 push 0x2001a2\(%rip\) # 2003d8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 a3 01 20 00 bnd jmp \*0x2001a3\(%rip\) # 2003e0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 01 00 00 00 push \$0x1
+[a-f0-9]+: f2 e9 d5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 02 00 00 00 push \$0x2
+[a-f0-9]+: f2 e9 c5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+[a-f0-9]+: 68 03 00 00 00 push \$0x3
+[a-f0-9]+: f2 e9 b5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+280 <foo2@plt>:
+[a-f0-9]+: f2 ff 25 61 01 20 00 bnd jmp \*0x200161\(%rip\) # 2003e8 <foo2>
+[a-f0-9]+: 90 nop
0+288 <foo3@plt>:
+[a-f0-9]+: f2 ff 25 61 01 20 00 bnd jmp \*0x200161\(%rip\) # 2003f0 <foo3>
+[a-f0-9]+: 90 nop
0+290 <foo1@plt>:
+[a-f0-9]+: f2 ff 25 61 01 20 00 bnd jmp \*0x200161\(%rip\) # 2003f8 <foo1>
+[a-f0-9]+: 90 nop
0+298 <foo4@plt>:
+[a-f0-9]+: f2 ff 25 61 01 20 00 bnd jmp \*0x200161\(%rip\) # 200400 <foo4>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+2a0 <_start>:
+[a-f0-9]+: f2 e9 ea ff ff ff bnd jmp 290 <foo1@plt>
+[a-f0-9]+: e8 d5 ff ff ff call 280 <foo2@plt>
+[a-f0-9]+: e9 d8 ff ff ff jmp 288 <foo3@plt>
+[a-f0-9]+: e8 e3 ff ff ff call 298 <foo4@plt>
+[a-f0-9]+: f2 e8 cd ff ff ff bnd call 288 <foo3@plt>
+[a-f0-9]+: e9 d8 ff ff ff jmp 298 <foo4@plt>
#pass

View file

@ -1,55 +0,0 @@
#source: bnd-branch-1.s
#as: --64 -mx86-used-note=no
#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
Disassembly of section .plt:
0+230 <.plt>:
[ ]*[a-f0-9]+: ff 35 82 01 20 00 push 0x200182\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: f2 ff 25 83 01 20 00 bnd jmp \*0x200183\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0
[ ]*[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 01 00 00 00 push \$0x1
[ ]*[a-f0-9]+: f2 e9 d5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 02 00 00 00 push \$0x2
[ ]*[a-f0-9]+: f2 e9 c5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
[ ]*[a-f0-9]+: 68 03 00 00 00 push \$0x3
[ ]*[a-f0-9]+: f2 e9 b5 ff ff ff bnd jmp 230 <foo2@plt-0x50>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+280 <foo2@plt>:
[ ]*[a-f0-9]+: f2 ff 25 41 01 20 00 bnd jmp \*0x200141\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+288 <foo3@plt>:
[ ]*[a-f0-9]+: f2 ff 25 41 01 20 00 bnd jmp \*0x200141\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+290 <foo1@plt>:
[ ]*[a-f0-9]+: f2 ff 25 41 01 20 00 bnd jmp \*0x200141\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
0+298 <foo4@plt>:
[ ]*[a-f0-9]+: f2 ff 25 41 01 20 00 bnd jmp \*0x200141\(%rip\)[ ]*(#.*)?
[ ]*[a-f0-9]+: 90 nop
Disassembly of section .text:
0+2a0 <_start>:
[ ]*[a-f0-9]+: f2 e9 ea ff ff ff bnd jmp 290 <foo1@plt>
[ ]*[a-f0-9]+: e8 d5 ff ff ff call 280 <foo2@plt>
[ ]*[a-f0-9]+: e9 d8 ff ff ff jmp 288 <foo3@plt>
[ ]*[a-f0-9]+: e8 e3 ff ff ff call 298 <foo4@plt>
[ ]*[a-f0-9]+: f2 e8 cd ff ff ff bnd call 288 <foo3@plt>
[ ]*[a-f0-9]+: e9 d8 ff ff ff jmp 298 <foo4@plt>
#pass

View file

@ -1,138 +0,0 @@
# Expect script for ELF MPX tests.
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# The following tests require running the executable generated by ld,
# or enough of a build environment to create a fully linked executable.
# This is not commonly available when testing a cross-built linker.
if ![isnative] {
return
}
# Only on Linux for now.
if ![istarget "x86_64-*-linux*"] {
return
}
# Check to see if the C compiler works
if { ![check_compiler_available] } {
return
}
run_cc_link_tests [list \
[list \
"Build libmpx1a.a" \
"" \
"-Wa,-madd-bnd-prefix -fPIC $PLT_CFLAGS" \
{mpx1a.c} \
{{readelf {-r --wide} mpx1a.rd}} \
"libmpx1a.a" \
] \
[list \
"Build libmpx1b.a" \
"" \
"" \
{mpx1b.c} \
{} \
"libmpx1b.a" \
] \
[list \
"Build libmpx1c.a" \
"" \
"-Wa,-madd-bnd-prefix" \
{mpx1c.c} \
{{readelf {-r --wide} mpx1c.rd}} \
"libmpx1c.a" \
] \
[list \
"Build libmpx2a.a" \
"" \
"-Wa,-madd-bnd-prefix -fPIE $PLT_CFLAGS" \
{mpx2a.c} \
{{readelf {-r --wide} mpx2a.rd}} \
"libmpx2a.a" \
] \
[list \
"Build libmpx2b.a" \
"" \
"-fPIE" \
{mpx2b.c} \
{} \
"libmpx2b.a" \
] \
[list \
"Build libmpx2c.a" \
"" \
"-Wa,-madd-bnd-prefix -fPIE $PLT_CFLAGS" \
{mpx2c.c} \
{{readelf {-r --wide} mpx2c.rd}} \
"libmpx2c.a" \
] \
]
set run_tests {
{"Run mpx1"
"tmpdir/mpx1a.o tmpdir/mpx1b.o tmpdir/mpx1c.o" ""
{dummy.s} "mpx1" "mpx1.out"}
{"Run mpx1 with -static"
"tmpdir/mpx1a.o tmpdir/mpx1b.o tmpdir/mpx1c.o -static" ""
{dummy.s} "mpx1static" "mpx1.out"}
{"Run mpx2"
"tmpdir/mpx2a.o tmpdir/mpx2b.o tmpdir/mpx2c.o -pie" ""
{dummy.s} "mpx2" "mpx2.out"}
{"Run mpx2 with -static"
"tmpdir/mpx2a.o tmpdir/mpx2b.o tmpdir/mpx2c.o -static" ""
{dummy.s} "mpx2static" "mpx2.out"}
}
run_ld_link_tests {
{"Build libcall.so"
"-m elf_x86_64 -shared -z bndplt" ""
"--64" {mpx3b.s} {} "libcall.so"}
{"Build mpx3"
"-m elf_x86_64 -z bndplt tmpdir/libcall.so" ""
"--64" {mpx3a.s} {{objdump -dw mpx3.dd}} "mpx3"}
{"Build libcall1.so"
"-m elf_x86_64 -shared -z bndplt" ""
"--64" {mpx4b.s} {} "libcall1.so"}
{"Build mpx4"
"-m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall1.so \
-z max-page-size=0x200000 -z noseparate-code" ""
"--64 -mx86-used-note=no" {mpx4a.s} {{objdump -dw mpx4.dd}} "mpx4"}
{"Build mpx3 (-z now)"
"-z now -m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall.so \
-z max-page-size=0x200000 -z noseparate-code" ""
"--64 -mx86-used-note=no" {mpx3a.s} {{objdump -dw mpx3n.dd}} "mpx3n"}
{"Build mpx4 (-z now)"
"-z now -m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall1.so \
-z max-page-size=0x200000 -z noseparate-code" ""
"--64 -mx86-used-note=no" {mpx4a.s} {{objdump -dw mpx4n.dd}} "mpx4n"}
}
run_ld_link_exec_tests $run_tests
run_dump_test "bnd-branch-1"
run_dump_test "bnd-ifunc-1"
run_dump_test "bnd-ifunc-2"
run_dump_test "bnd-plt-1"
run_dump_test "bnd-branch-1-now"
run_dump_test "bnd-ifunc-1-now"
run_dump_test "bnd-ifunc-2-now"
run_dump_test "bnd-plt-1-now"

View file

@ -1,2 +0,0 @@
foo1
foo2

View file

@ -1,7 +0,0 @@
#include <stdio.h>
void
foo1 (void)
{
printf ("foo1\n");
}

View file

@ -1,3 +0,0 @@
#...
[0-9a-f ]+R_X86_64_PLT32 +0+ +.*
#...

View file

@ -1,7 +0,0 @@
#include <stdio.h>
void
foo2 (void)
{
printf ("foo2\n");
}

View file

@ -1,10 +0,0 @@
extern void foo1 (void);
extern void foo2 (void);
int
main (void)
{
foo1 ();
foo2 ();
return 0;
}

View file

@ -1,3 +0,0 @@
#...
[0-9a-f ]+R_X86_64_PLT32 +0+ +.*
#...

View file

@ -1,2 +0,0 @@
foo1
foo2

View file

@ -1,7 +0,0 @@
#include <stdio.h>
void
foo1 (void)
{
printf ("foo1\n");
}

View file

@ -1,3 +0,0 @@
#...
[0-9a-f ]+R_X86_64_PLT32 +0+ +.*
#...

View file

@ -1,7 +0,0 @@
#include <stdio.h>
void
foo2 (void)
{
printf ("foo2\n");
}

View file

@ -1,10 +0,0 @@
extern void foo1 (void);
extern void foo2 (void);
int
main (void)
{
foo1 ();
foo2 ();
return 0;
}

View file

@ -1,3 +0,0 @@
#...
[0-9a-f ]+R_X86_64_PLT32 +0+ +.*
#...

View file

@ -1,28 +0,0 @@
.*: +file format .*
Disassembly of section .plt:
0+[a-f0-9]+ <.plt>:
[ ]*[a-f0-9]+: ff ([0-9a-f]{2} ){5} push 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8>
[ ]*[a-f0-9]+: f2 ff ([0-9a-f]{2} ){5} bnd jmp \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10>
[ ]*[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0
[ ]*[a-f0-9]+: f2 e9 ([0-9a-f]{2} ){4} bnd jmp [a-f0-9]+ <call1@plt-0x20>
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+[a-f0-9]+ <call1@plt>:
[ ]*[a-f0-9]+: f2 ff ([0-9a-f]{2} ){5} bnd jmp \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <call1>
[ ]*[a-f0-9]+: 90 nop
Disassembly of section .text:
0+[a-f0-9]+ <_start>:
[ ]*[a-f0-9]+: bf ([0-9a-f]{2} ){4} mov \$0x[a-f0-9]+,%edi
[ ]*[a-f0-9]+: f2 ff d7 bnd call \*%rdi
[ ]*[a-f0-9]+: 48 8b ([0-9a-f]{2} ){5} mov 0x[a-f0-9]+\(%rip\),%rdi # [a-f0-9]+ <call2>
[ ]*[a-f0-9]+: f2 ff d7 bnd call \*%rdi
[ ]*[a-f0-9]+: c3 ret *
#pass

View file

@ -1,16 +0,0 @@
.text
.globl _start
.type _start, @function
_start:
movl $call1, %edi
bnd call *%rdi
movq func(%rip), %rdi
bnd call *%rdi
ret
.size _start, .-_start
.globl func
.data
.type func, @object
.size func, 8
func:
.quad call2

View file

@ -1,11 +0,0 @@
.text
.globl call1
.type call1, @function
call1:
ret
.size call1, .-call1
.globl call2
.type call2, @function
call2:
ret
.size call2, .-call2

View file

@ -1,28 +0,0 @@
.*: +file format .*
Disassembly of section .plt:
0+400220 <.plt>:
+[a-f0-9]+: ff 35 a2 01 20 00 push 0x2001a2\(%rip\) # 6003c8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 a3 01 20 00 bnd jmp \*0x2001a3\(%rip\) # 6003d0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 400220 <call1@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+400240 <call1@plt>:
+[a-f0-9]+: f2 ff 25 91 01 20 00 bnd jmp \*0x200191\(%rip\) # 6003d8 <call1>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+400248 <_start>:
+[a-f0-9]+: bf 40 02 40 00 mov \$0x400240,%edi
+[a-f0-9]+: f2 ff d7 bnd call \*%rdi
+[a-f0-9]+: 48 8b 3d 89 01 20 00 mov 0x200189\(%rip\),%rdi # 6003e0 <call2>
+[a-f0-9]+: f2 ff d7 bnd call \*%rdi
+[a-f0-9]+: c3 ret *
#pass

View file

@ -1,24 +0,0 @@
.*: +file format .*
Disassembly of section .plt:
0+4001f0 <.plt>:
+[a-f0-9]+: ff 35 42 01 20 00 push 0x200142\(%rip\) # 600338 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 43 01 20 00 bnd jmp \*0x200143\(%rip\) # 600340 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 4001f0 <call1@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+400210 <call1@plt>:
+[a-f0-9]+: f2 ff 25 31 01 20 00 bnd jmp \*0x200131\(%rip\) # 600348 <call1>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+400218 <_start>:
+[a-f0-9]+: bf 10 02 40 00 mov \$0x400210,%edi
+[a-f0-9]+: f2 ff d7 bnd call \*%rdi

View file

@ -1,6 +0,0 @@
.text
.globl _start
.type _start, @function
_start:
movl $call1, %edi
bnd call *%rdi

View file

@ -1,5 +0,0 @@
.text
.globl call1
.type call1, @function
call1:
ret

View file

@ -1,25 +0,0 @@
.*: +file format .*
Disassembly of section .plt:
0+4001f0 <.plt>:
+[a-f0-9]+: ff 35 62 01 20 00 push 0x200162\(%rip\) # 600358 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 63 01 20 00 bnd jmp \*0x200163\(%rip\) # 600360 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 4001f0 <call1@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+400210 <call1@plt>:
+[a-f0-9]+: f2 ff 25 51 01 20 00 bnd jmp \*0x200151\(%rip\) # 600368 <call1>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+400218 <_start>:
+[a-f0-9]+: bf 10 02 40 00 mov \$0x400210,%edi
+[a-f0-9]+: f2 ff d7 bnd call \*%rdi
#pass

View file

@ -1,18 +0,0 @@
.text
.globl main
.type main, @function
main:
.L2:
leaq .L2(%rip), %rax
movabsq $_GLOBAL_OFFSET_TABLE_-.L2, %r11
movabsq $bar@PLTOFF, %rdx
pushq %r15
addq %r11, %rax
movq %rax, %r15
addq %rax, %rdx
call *%rdx
xorl %eax, %eax
popq %r15
ret
.size main, .-main
.section .note.GNU-stack

View file

@ -1,21 +0,0 @@
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "PASS\n"
.text
.globl bar
.type bar, @function
bar:
.L2:
leaq .L2(%rip), %rdx
movabsq $_GLOBAL_OFFSET_TABLE_-.L2, %r11
movabsq $.LC0@GOTOFF, %rax
pushq %r15
movabsq $printf@PLTOFF, %rcx
addq %r11, %rdx
popq %r15
leaq (%rdx,%rax), %rdi
addq %rdx, %rcx
xorl %eax, %eax
jmp *%rcx
.size bar, .-bar
.section .note.GNU-stack,"",@progbits

View file

@ -1,68 +0,0 @@
#name: PR ld/21038 (.plt.got, -z now)
#source: pr21038a.s
#as: --64
#ld: -z now -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001c8..00000000000001d4
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001b0..00000000000001c0
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001b6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 00000000000001c0
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000001c0..00000000000001c8
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1b0 <.plt>:
+[a-f0-9]+: ff 35 32 fe 3f 00 push 0x3ffe32\(%rip\) # 3fffe8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 33 fe 3f 00 bnd jmp \*0x3ffe33\(%rip\) # 3ffff0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
Disassembly of section .plt.got:
0+1c0 <func@plt>:
+[a-f0-9]+: f2 ff 25 31 fe 3f 00 bnd jmp \*0x3ffe31\(%rip\) # 3ffff8 <func>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+1c8 <foo>:
+[a-f0-9]+: e8 f3 ff ff ff call 1c0 <func@plt>
+[a-f0-9]+: 48 8b 05 24 fe 3f 00 mov 0x3ffe24\(%rip\),%rax # 3ffff8 <func>
#pass

View file

@ -1,67 +0,0 @@
#name: PR ld/21038 (.plt.got)
#as: --64
#ld: -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001c8..00000000000001d4
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001b0..00000000000001c0
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001b6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 00000000000001c0
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000001c0..00000000000001c8
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1b0 <.plt>:
+[a-f0-9]+: ff 35 3a fe 3f 00 push 0x3ffe3a\(%rip\) # 3ffff0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 3b fe 3f 00 bnd jmp \*0x3ffe3b\(%rip\) # 3ffff8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
Disassembly of section .plt.got:
0+1c0 <func@plt>:
+[a-f0-9]+: f2 ff 25 19 fe 3f 00 bnd jmp \*0x3ffe19\(%rip\) # 3fffe0 <func>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+1c8 <foo>:
+[a-f0-9]+: e8 f3 ff ff ff call 1c0 <func@plt>
+[a-f0-9]+: 48 8b 05 0c fe 3f 00 mov 0x3ffe0c\(%rip\),%rax # 3fffe0 <func>
#pass

View file

@ -1,8 +0,0 @@
.text
.globl foo
.type foo, @function
foo:
.cfi_startproc
call func@plt
movq func@GOTPCREL(%rip), %rax
.cfi_endproc

View file

@ -1,70 +0,0 @@
#name: PR ld/21038 (.plt.sec, -z now)
#source: pr21038b.s
#as: --64
#ld: -z now -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001d8..00000000000001dd
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001b0..00000000000001d0
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001b6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 00000000000001c0
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000001d0..00000000000001d8
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1b0 <.plt>:
+[a-f0-9]+: ff 35 32 fe 3f 00 push 0x3ffe32\(%rip\) # 3fffe8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 33 fe 3f 00 bnd jmp \*0x3ffe33\(%rip\) # 3ffff0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 1b0 <func@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+1d0 <func@plt>:
+[a-f0-9]+: f2 ff 25 21 fe 3f 00 bnd jmp \*0x3ffe21\(%rip\) # 3ffff8 <func>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+1d8 <foo>:
+[a-f0-9]+: e8 f3 ff ff ff call 1d0 <func@plt>
#pass

View file

@ -1,69 +0,0 @@
#name: PR ld/21038 (.plt.sec)
#as: --64
#ld: -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001d8..00000000000001dd
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001b0..00000000000001d0
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001b6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 00000000000001c0
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000001d0..00000000000001d8
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1b0 <.plt>:
+[a-f0-9]+: ff 35 3a fe 3f 00 push 0x3ffe3a\(%rip\) # 3ffff0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 3b fe 3f 00 bnd jmp \*0x3ffe3b\(%rip\) # 3ffff8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 1b0 <func@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.sec:
0+1d0 <func@plt>:
+[a-f0-9]+: f2 ff 25 29 fe 3f 00 bnd jmp \*0x3ffe29\(%rip\) # 400000 <func>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+1d8 <foo>:
+[a-f0-9]+: e8 f3 ff ff ff call 1d0 <func@plt>
#pass

View file

@ -1,7 +0,0 @@
.text
.globl foo
.type foo, @function
foo:
.cfi_startproc
call func@plt
.cfi_endproc

View file

@ -1,87 +0,0 @@
#name: PR ld/21038 (.plt.got and .plt.sec, -z now)
#source: pr21038c.s
#as: --64
#ld: -z now -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=0000000000000220..0000000000000231
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001f0..0000000000000210
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001f6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 0000000000000200
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000014 0000005c FDE cie=00000000 pc=0000000000000210..0000000000000218
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+70 0000000000000010 00000074 FDE cie=00000000 pc=0000000000000218..0000000000000220
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1f0 <.plt>:
+[a-f0-9]+: ff 35 ea fd 3f 00 push 0x3ffdea\(%rip\) # 3fffe0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 eb fd 3f 00 bnd jmp \*0x3ffdeb\(%rip\) # 3fffe8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 1f0 <func1@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.got:
0+210 <func1@plt>:
+[a-f0-9]+: f2 ff 25 e1 fd 3f 00 bnd jmp \*0x3ffde1\(%rip\) # 3ffff8 <func1>
+[a-f0-9]+: 90 nop
Disassembly of section .plt.sec:
0+218 <func2@plt>:
+[a-f0-9]+: f2 ff 25 d1 fd 3f 00 bnd jmp \*0x3ffdd1\(%rip\) # 3ffff0 <func2>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+220 <foo>:
+[a-f0-9]+: e8 eb ff ff ff call 210 <func1@plt>
+[a-f0-9]+: e8 ee ff ff ff call 218 <func2@plt>
+[a-f0-9]+: 48 8b 05 c7 fd 3f 00 mov 0x3ffdc7\(%rip\),%rax # 3ffff8 <func1>
#pass

View file

@ -1,86 +0,0 @@
#name: PR ld/21038 (.plt.got and .plt.sec)
#as: --64
#ld: -z bndplt -melf_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000014 0000001c FDE cie=00000000 pc=0000000000000220..0000000000000231
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+30 0000000000000024 00000034 FDE cie=00000000 pc=00000000000001f0..0000000000000210
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000000001f6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 0000000000000200
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+58 0000000000000014 0000005c FDE cie=00000000 pc=0000000000000210..0000000000000218
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+70 0000000000000010 00000074 FDE cie=00000000 pc=0000000000000218..0000000000000220
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+1f0 <.plt>:
+[a-f0-9]+: ff 35 fa fd 3f 00 push 0x3ffdfa\(%rip\) # 3ffff0 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: f2 ff 25 fb fd 3f 00 bnd jmp \*0x3ffdfb\(%rip\) # 3ffff8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+[a-f0-9]+: 68 00 00 00 00 push \$0x0
+[a-f0-9]+: f2 e9 e5 ff ff ff bnd jmp 1f0 <func1@plt-0x20>
+[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
Disassembly of section .plt.got:
0+210 <func1@plt>:
+[a-f0-9]+: f2 ff 25 c9 fd 3f 00 bnd jmp \*0x3ffdc9\(%rip\) # 3fffe0 <func1>
+[a-f0-9]+: 90 nop
Disassembly of section .plt.sec:
0+218 <func2@plt>:
+[a-f0-9]+: f2 ff 25 e1 fd 3f 00 bnd jmp \*0x3ffde1\(%rip\) # 400000 <func2>
+[a-f0-9]+: 90 nop
Disassembly of section .text:
0+220 <foo>:
+[a-f0-9]+: e8 eb ff ff ff call 210 <func1@plt>
+[a-f0-9]+: e8 ee ff ff ff call 218 <func2@plt>
+[a-f0-9]+: 48 8b 05 af fd 3f 00 mov 0x3ffdaf\(%rip\),%rax # 3fffe0 <func1>
#pass

View file

@ -1,9 +0,0 @@
.text
.globl foo
.type foo, @function
foo:
.cfi_startproc
call func1@plt
call func2@plt
movq func1@GOTPCREL(%rip), %rax
.cfi_endproc

View file

@ -2002,130 +2002,6 @@ if { [isnative] && [check_compiler_available] } {
]
}
if { [istarget "x86_64-*-linux*"] \
&& ![istarget "x86_64-*-linux*-gnux32"]} {
run_cc_link_tests [list \
[list \
"Build plt-main with -z bndplt" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,bndplt \
-Wl,-z,noseparate-code,-z,max-page-size=0x200000" \
"-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{objdump {-drw} plt-main-bnd.dd}} \
"plt-main-bnd" \
] \
[list \
"Build plt-main with PIE and -z bndplt" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
-Wl,-z,bndplt,-z,noseparate-code \
-Wl,-z,max-page-size=0x200000" \
"-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{objdump {-drw} plt-main-bnd.dd}} \
"plt-main-pie-bnd" \
] \
[list \
"Build plt-main with -z bndplt -z now" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,bndplt \
-Wl,-z,now,-z,noseparate-code,-z,max-page-size=0x200000" \
"-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
"plt-main-bnd-now" \
] \
[list \
"Build plt-main with PIE and -z bndplt -z now" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
-Wl,-z,bndplt,-z,now,-z,noseparate-code \
-Wl,-z,max-page-size=0x200000" \
"-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
"plt-main-pie-bnd-now" \
] \
]
run_ld_link_exec_tests [list \
[list \
"Run plt-main with -z bndplt" \
"-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
"-Wa,-mx86-used-note=yes" \
{ plt-main5.c } \
"plt-main-bnd" \
"plt-main.out" \
] \
[list \
"Run plt-main with PIE and -z bndplt" \
"-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
"-Wa,-mx86-used-note=yes" \
{ plt-main5.c } \
"plt-main-pie-bnd" \
"plt-main.out" \
"-fPIC" \
] \
[list \
"Run plt-main with -z bndplt -z now" \
"-Wl,--no-as-needed,-z,bndplt,-z,now tmpdir/plt-main1.o \
tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
"-Wa,-mx86-used-note=yes" \
{ plt-main5.c } \
"plt-main-bnd-now" \
"plt-main.out" \
] \
[list \
"Run plt-main with PIE and -z bndplt -z now" \
"-Wl,--no-as-needed,-z,bndplt,-z,now -pie tmpdir/plt-main1.o \
tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
"-Wa,-mx86-used-note=yes" \
{ plt-main5.c } \
"plt-main-pie-bnd-now" \
"plt-main.out" \
"-fPIC" \
] \
[list \
"Run pr20800" \
"-Wl,-z,now -pie" \
"-Wa,-mx86-used-note=yes" \
{ pr20800a.S pr20800b.S } \
"pr20800" \
"pass.out" \
] \
]
if { [check_ifunc_attribute_available] } {
run_ld_link_exec_tests [list \
[list \
"Run pr21481a" \
"$NOPIE_LDFLAGS -Wl,-z,bndplt" \
"-Wa,-mx86-used-note=yes" \
{ pr21481a.c pr21481b.S } \
"pr21481a" \
"pass.out" \
"$NOPIE_CFLAGS" \
] \
[list \
"Run pr21481b" \
"$NOPIE_LDFLAGS -Wl,-z,bndplt,-z,now" \
"-Wa,-mx86-used-note=yes" \
{ pr21481a.c pr21481b.S } \
"pr21481b" \
"pass.out" \
"$NOPIE_CFLAGS" \
] \
]
}
}
if { [istarget "x86_64-*-linux*"] } {
set pltdump {{objdump {-drw} plt-main-ibt.dd}}
set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
@ -2331,14 +2207,8 @@ run_dump_test "pltgot-1"
run_dump_test "pltgot-2"
run_dump_test "pr20830a"
run_dump_test "pr20830b"
run_dump_test "pr21038a"
run_dump_test "pr21038b"
run_dump_test "pr21038c"
run_dump_test "pr20830a-now"
run_dump_test "pr20830b-now"
run_dump_test "pr21038a-now"
run_dump_test "pr21038b-now"
run_dump_test "pr21038c-now"
run_dump_test "ibt-plt-1"
run_dump_test "ibt-plt-1-x32"
run_dump_test "ibt-plt-2a"