mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
68b007788a
Linker generated relative relocations don't have symbol info: [hjl@gnu-cfl-2 tmpdir]$ readelf -rW dump Relocation section '.rela.dyn' at offset 0x180 contains 2 entries: Offset Info Type Sym. Value Symbol's Name + Addend 00002f70 00000008 R_X86_64_RELATIVE 1000 00002f68 00000025 R_X86_64_IRELATIVE 1007 [hjl@gnu-cfl-2 tmpdir]$ Add -z report-relative-reloc to x86 ELF linker to report dynamic relative relocations: [hjl@gnu-cfl-2 tmpdir]$ ../ld-new -pie -melf32_x86_64 -z report-relative-reloc -o dump report-reloc-1.o dump: R_X86_64_IRELATIVE (offset: 0x00002f68, info: 0x00000025, addend: 0x00001007) against 'ifunc' for section '.data.rel.ro.local' in report-reloc-1.o dump: R_X86_64_RELATIVE (offset: 0x00002f70, info: 0x00000008, addend: 0x00001000) against '_start' for section '.data.rel.ro.local' in report-reloc-1.o [hjl@gnu-cfl-2 tmpdir]$ It can be used to map relative relocations to corresponding symbols. bfd/ * elf-linker-x86.h (elf_linker_x86_params): Add report_relative_reloc. * elf32-i386.c (elf_i386_relocate_section): Call _bfd_x86_elf_link_report_relative_reloc to report relative relocations for -z report-relative-reloc. (elf_i386_finish_dynamic_symbol): Likewse. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewse. (elf_x86_64_finish_dynamic_symbol): Likewse. * elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): New function. * elfxx-x86.h (_bfd_x86_elf_link_report_relative_reloc): New prototype. ld/ * NEWS: Mention -z report-relative-reloc. * ld.texi: Document -z report-relative-reloc. * emulparams/elf32_x86_64.sh: Source x86-report-relative.sh. * emulparams/elf_i386.sh: Likewse. * emulparams/elf_x86_64.sh: Likewse. * emulparams/x86-report-relative.sh: New file. * testsuite/ld-i386/report-reloc-1.d: Likewse. * testsuite/ld-i386/report-reloc-1.l: Likewse. * testsuite/ld-i386/report-reloc-1.s: Likewse. * testsuite/ld-x86-64/report-reloc-1-x32.d: Likewse. * testsuite/ld-x86-64/report-reloc-1.d: Likewse. * testsuite/ld-x86-64/report-reloc-1.l: Likewse. * testsuite/ld-x86-64/report-reloc-1.s: Likewse. * testsuite/ld-i386/i386.exp: Run report-reloc-1. * testsuite/ld-x86-64/x86-64.exp: Run report-reloc-1 and report-reloc-1-x32.
85 lines
2.9 KiB
C
85 lines
2.9 KiB
C
/* x86-specific ELF linker support between ld and bfd.
|
|
Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
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. */
|
|
|
|
/* Missing IBT, SHSTK and LAM property report control. */
|
|
enum elf_x86_prop_report
|
|
{
|
|
prop_report_none = 0, /* Do nothing. */
|
|
prop_report_warning = 1 << 0, /* Issue a warning. */
|
|
prop_report_error = 1 << 1, /* Issue an error. */
|
|
prop_report_ibt = 1 << 2, /* Report missing IBT property. */
|
|
prop_report_shstk = 1 << 3 /* Report missing SHSTK property. */
|
|
};
|
|
|
|
/* 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;
|
|
|
|
/* TRUE if GNU_PROPERTY_X86_FEATURE_1_IBT should be generated. */
|
|
unsigned int ibt: 1;
|
|
|
|
/* TRUE if GNU_PROPERTY_X86_FEATURE_1_SHSTK should be generated. */
|
|
unsigned int shstk: 1;
|
|
|
|
/* TRUE if GNU_PROPERTY_X86_FEATURE_1_LAM_U48 should be generated. */
|
|
unsigned int lam_u48: 1;
|
|
|
|
/* TRUE if GNU_PROPERTY_X86_FEATURE_1_LAM_U57 should be generated. */
|
|
unsigned int lam_u57: 1;
|
|
|
|
/* TRUE if we shouldn't check relocation overflow. */
|
|
unsigned int no_reloc_overflow_check: 1;
|
|
|
|
/* TRUE if generate a 1-byte NOP as suffix for x86 call instruction. */
|
|
unsigned int call_nop_as_suffix : 1;
|
|
|
|
/* TRUE if -static is passed at command-line before all input files. */
|
|
unsigned int static_before_all_inputs : 1;
|
|
|
|
/* TRUE if --dynamic-linker is passed at command-line. */
|
|
unsigned int has_dynamic_linker : 1;
|
|
|
|
/* Report relative relocations. */
|
|
unsigned int report_relative_reloc : 1;
|
|
|
|
/* X86-64 ISA level needed. */
|
|
unsigned int isa_level;
|
|
|
|
/* Report missing IBT and SHSTK properties. */
|
|
enum elf_x86_prop_report cet_report;
|
|
|
|
/* Report missing LAM_U48 property. */
|
|
enum elf_x86_prop_report lam_u48_report;
|
|
|
|
/* Report missing LAM_U57 property. */
|
|
enum elf_x86_prop_report lam_u57_report;
|
|
|
|
/* The 1-byte NOP for x86 call instruction. */
|
|
char call_nop_byte;
|
|
};
|
|
|
|
extern void _bfd_elf_linker_x86_set_options
|
|
(struct bfd_link_info *, struct elf_linker_x86_params *);
|