aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-04-17 10:22:19 -0700
committerH.J. Lu <hjl.tools@gmail.com>2019-04-17 10:25:28 -0700
commit9a7f0679fd3b9815b8eb938bfdad3934b8435419 (patch)
tree4b1d7e65292f9e4e1fa93e26ede4e885ddf553c2 /bfd
parent4e84a8f8bbeab52fa7048873655e582ceb92534d (diff)
downloadgdb-9a7f0679fd3b9815b8eb938bfdad3934b8435419.zip
gdb-9a7f0679fd3b9815b8eb938bfdad3934b8435419.tar.gz
gdb-9a7f0679fd3b9815b8eb938bfdad3934b8435419.tar.bz2
x86: Suggest -fPIE when not building shared object
When PIC is needed, linker should suggest -fPIE, instead of -fPIC, when not building shared object. bfd/ * elf64-x86-64.c (elf_x86_64_need_pic): Suggest -fPIE when not building shared object. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Likewise. ld/ * testsuite/ld-i386/i386.exp: Run pr18801a and pr18801b instead of pr18801. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr18801.d: Removed. * testsuite/ld-x86-64/pr18801.d: Likewise. * testsuite/ld-i386/pr18801a.d: New file. * testsuite/ld-i386/pr18801b.d: Likewise. * testsuite/ld-x86-64/pr18801a.d: Likewise. * testsuite/ld-x86-64/pr18801b.d: Likewise. * testsuite/ld-x86-64/pie2.d: Suggest -fPIE instead of -fPIC. * testsuite/ld-x86-64/pie2.d: Likewise. * testsuite/ld-x86-64/pr19719.d: Likewise. * testsuite/ld-x86-64/pr19807-2a.d: Likewise. * testsuite/ld-x86-64/pr19969.d: Likewise. * testsuite/ld-x86-64/pr21997-1a.err: Likewise. * testsuite/ld-x86-64/pr21997-1b.err: Likewise. * testsuite/ld-x86-64/pr22001-1a.err: Likewise. * testsuite/ld-x86-64/pr22001-1b.err: Likewise. * testsuite/ld-x86-64/pr22791-1.err: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf64-x86-64.c21
-rw-r--r--bfd/elfxx-x86.c3
3 files changed, 23 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2d1c14f..e61981f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2019-04-17 H.J. Lu <hongjiu.lu@intel.com>
+ * elf64-x86-64.c (elf_x86_64_need_pic): Suggest -fPIE when not
+ building shared object.
+ * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Likewise.
+
+2019-04-17 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/24458
* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): Also check x86
linker_def.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 27e23a0..2f69239 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1422,7 +1422,7 @@ elf_x86_64_need_pic (struct bfd_link_info *info,
v = _("protected symbol ");
else
v = _("symbol ");
- pic = _("; recompile with -fPIC");
+ pic = NULL;
break;
}
@@ -1432,15 +1432,24 @@ elf_x86_64_need_pic (struct bfd_link_info *info,
else
{
name = bfd_elf_sym_name (input_bfd, symtab_hdr, isym, NULL);
- pic = _("; recompile with -fPIC");
+ pic = NULL;
}
if (bfd_link_dll (info))
- object = _("a shared object");
- else if (bfd_link_pie (info))
- object = _("a PIE object");
+ {
+ object = _("a shared object");
+ if (!pic)
+ pic = _("; recompile with -fPIC");
+ }
else
- object = _("a PDE object");
+ {
+ if (bfd_link_pie (info))
+ object = _("a PIE object");
+ else
+ object = _("a PDE object");
+ if (!pic)
+ pic = _("; recompile with -fPIE");
+ }
/* xgettext:c-format */
_bfd_error_handler (_("%pB: relocation %s against %s%s`%s' can "
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index e661ad3..78ed41a 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -1381,7 +1381,8 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
{
info->callbacks->einfo
(_("%P%X: read-only segment has dynamic IFUNC relocations;"
- " recompile with -fPIC\n"));
+ " recompile with %s\n"),
+ bfd_link_dll (info) ? "-fPIC" : "-fPIE");
bfd_set_error (bfd_error_bad_value);
return FALSE;
}