aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-x86.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-04-06 07:25:10 -0700
committerH.J. Lu <hjl.tools@gmail.com>2019-04-06 07:25:31 -0700
commit5b9c07b2782fb9368f06c2561b7329c384ec5da0 (patch)
tree7258bdae0c83c09117cd939b2e770521c5604dc6 /bfd/elfxx-x86.c
parentd55e5aa6b29906346c51ad00e6a9b112590aa294 (diff)
downloadgdb-5b9c07b2782fb9368f06c2561b7329c384ec5da0.zip
gdb-5b9c07b2782fb9368f06c2561b7329c384ec5da0.tar.gz
gdb-5b9c07b2782fb9368f06c2561b7329c384ec5da0.tar.bz2
x86: Move x86-specific linker options to elf_linker_x86_params
Remove x86-specific linker options from bfd_link_info and put them in elf_linker_x86_params. Add _bfd_elf_linker_x86_set_options to pass x86-specific linker options from ld to bfd. bfd/ * elf-linker-x86.h: New file. * elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params to get x86-specific linker options. * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise. (elf_x86_64_check_relocs): Likewise. (elf_x86_64_relocate_section): Likewise. (elf_x86_64_link_setup_gnu_properties): Likewise. * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise. (_bfd_x86_elf_link_setup_gnu_properties): Likewise. (_bfd_elf_linker_x86_set_options): New function. * elfxx-x86.h: Include "elf-linker-x86.h". (elf_x86_link_hash_table): Add params. include/ * bfdlink.h (bfd_link_info): Remove x86-specific linker options. ld/ * Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em. (eelf_i386_sol2.c): Also depend on $(srcdir)/emultempl/solaris2-x86.em. (eelf_x86_64_sol2.c): Likewise. * Makefile.in: Regenerated. * emulparams/call_nop.sh: Set x86-specific linker options via params. * emulparams/cet.sh: Likewise. * emulparams/reloc_overflow.sh: Likewise. * emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New. Set to "elf-x86". * emulparams/elf_i386.sh: Likewise. * emulparams/elf_i386_be.sh: Likewise. * emulparams/elf_i386_chaos.sh: Likewise. * emulparams/elf_i386_ldso.sh: Likewise. * emulparams/elf_i386_vxworks.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to "solaris2-x86". * emulparams/elf_x86_64_sol2.sh: Likewise. * emultempl/elf-x86.em: New file. * emultempl/solaris2-x86.em: Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't set link_info.call_nop_byte.
Diffstat (limited to 'bfd/elfxx-x86.c')
-rw-r--r--bfd/elfxx-x86.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 5703b5f..8d08a69 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2479,12 +2479,18 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
2. If APROP is NULL, remove x86 feature.
3. Otherwise, do nothing.
*/
+ const struct elf_backend_data *bed
+ = get_elf_backend_data (info->output_bfd);
+ struct elf_x86_link_hash_table *htab
+ = elf_x86_hash_table (info, bed->target_id);
+ if (!htab)
+ abort ();
if (aprop != NULL && bprop != NULL)
{
features = 0;
- if (info->ibt)
+ if (htab->params->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
- if (info->shstk)
+ if (htab->params->shstk)
features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
number = aprop->u.number;
/* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
@@ -2501,9 +2507,9 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
have them. Set IBT and SHSTK properties for -z ibt and -z
shstk if needed. */
features = 0;
- if (info->ibt)
+ if (htab->params->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
- if (info->shstk)
+ if (htab->params->shstk)
features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
if (features)
{
@@ -2556,12 +2562,6 @@ _bfd_x86_elf_link_setup_gnu_properties
unsigned int class_align = ABI_64_P (info->output_bfd) ? 3 : 2;
unsigned int got_align;
- features = 0;
- if (info->ibt)
- features = GNU_PROPERTY_X86_FEATURE_1_IBT;
- if (info->shstk)
- features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
-
/* Find a normal input file with GNU property note. */
for (pbfd = info->input_bfds;
pbfd != NULL;
@@ -2581,6 +2581,12 @@ _bfd_x86_elf_link_setup_gnu_properties
if (htab == NULL)
return pbfd;
+ features = 0;
+ if (htab->params->ibt)
+ features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (htab->params->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
+
if (ebfd != NULL)
{
prop = NULL;
@@ -2630,7 +2636,7 @@ error_alignment:
htab->plt0_pad_byte = init_table->plt0_pad_byte;
- use_ibt_plt = info->ibtplt || info->ibt;
+ use_ibt_plt = htab->params->ibtplt || htab->params->ibt;
if (!use_ibt_plt && pbfd != NULL)
{
/* Check if GNU_PROPERTY_X86_FEATURE_1_IBT is on. */
@@ -2853,7 +2859,7 @@ error_alignment:
plt_alignment))
goto error_alignment;
}
- else if (info->bndplt && ABI_64_P (dynobj))
+ else if (htab->params->bndplt && ABI_64_P (dynobj))
{
/* Create the second PLT for Intel MPX support. MPX
PLT is supported only for non-NaCl target in 64-bit
@@ -2984,3 +2990,15 @@ _bfd_x86_elf_link_fixup_gnu_properties
}
}
}
+
+void
+_bfd_elf_linker_x86_set_options (struct bfd_link_info * info,
+ struct elf_linker_x86_params *params)
+{
+ const struct elf_backend_data *bed
+ = get_elf_backend_data (info->output_bfd);
+ struct elf_x86_link_hash_table *htab
+ = elf_x86_hash_table (info, bed->target_id);
+ if (htab != NULL)
+ htab->params = params;
+}