aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-04-01 09:59:46 +1030
committerAlan Modra <amodra@gmail.com>2015-04-07 23:00:07 +0930
commitd3e454b956b16d31998fec65a2508256e6357194 (patch)
tree8b6ee54cb49bcdd984c9df244ce6cfc225d7f496 /ld
parentd9b67d9f4127191679c743d1f47d2421d6dcede7 (diff)
downloadgdb-d3e454b956b16d31998fec65a2508256e6357194.zip
gdb-d3e454b956b16d31998fec65a2508256e6357194.tar.gz
gdb-d3e454b956b16d31998fec65a2508256e6357194.tar.bz2
PowerPC non-PIC to PIC editing for protected var access
This is a linker-only solution to the incompatibility between shared library protected visibility variables and using .dynbss and copy relocs for non-PIC access to shared library variables. bfd/ * elf32-ppc.c (struct ppc_elf_link_hash_entry): Add has_addr16_ha and has_addr16_lo. Make has_sda_refs a bitfield. (ppc_elf_check_relocs): Set new flags. (ppc_elf_link_hash_table_create): Update default_params. (ppc_elf_adjust_dynamic_symbol): Clear protected_def in cases where we won't be making .dynbss entries or editing code. Set params->pic_fixup when we'll edit code for protected var access. (allocate_dynrelocs): Allocate got entry for edited code and discard dyn_relocs. (struct ppc_elf_relax_info): Add picfixup_size. (ppc_elf_relax_section): Rename struct one_fixup to struct one_branch_fixup. Rename fixups to branch_fixups. Size space for pic fixups. (ppc_elf_relocate_section): Edit non-PIC accessing protected visibility variables to PIC. Don't emit dyn_relocs for code we've edited. * elf32-ppc.h (struct ppc_elf_params): Add pic_fixup. ld/ * emultempl/ppc32elf.em: Handle --no-pic-fixup. (params): Init new field. (ppc_before_allocation): Enable relaxation for pic_fixup.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/emultempl/ppc32elf.em15
2 files changed, 18 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 91e8c11..befab2c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-07 Alan Modra <amodra@gmail.com>
+
+ * emultempl/ppc32elf.em: Handle --no-pic-fixup.
+ (params): Init new field.
+ (ppc_before_allocation): Enable relaxation for pic_fixup.
+
2015-04-02 Andrew Turner <andrew@freebsd.org>
* Makefile.am: Add FreeBSD aarch64 files.
diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em
index 719e57f..41ff746 100644
--- a/ld/emultempl/ppc32elf.em
+++ b/ld/emultempl/ppc32elf.em
@@ -41,7 +41,7 @@ static int old_got = 0;
static bfd_vma pagesize = 0;
-static struct ppc_elf_params params = { PLT_UNSET, -1, 0, 0, 0, 0 };
+static struct ppc_elf_params params = { PLT_UNSET, -1, 0, 0, 0, 0, 0 };
static void
ppc_after_open_output (void)
@@ -172,7 +172,9 @@ ppc_before_allocation (void)
params.branch_trampolines = 1;
}
- if (params.ppc476_workaround || params.branch_trampolines)
+ if (params.branch_trampolines
+ || params.ppc476_workaround
+ || params.pic_fixup > 0)
ENABLE_RELAXATION;
}
@@ -249,6 +251,7 @@ PARSE_AND_LIST_PROLOGUE=${PARSE_AND_LIST_PROLOGUE}'
#define OPTION_NO_STUBSYMS (OPTION_STUBSYMS + 1)
#define OPTION_PPC476_WORKAROUND (OPTION_NO_STUBSYMS + 1)
#define OPTION_NO_PPC476_WORKAROUND (OPTION_PPC476_WORKAROUND + 1)
+#define OPTION_NO_PICFIXUP (OPTION_NO_PPC476_WORKAROUND + 1)
'
PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
@@ -265,6 +268,7 @@ fi
PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
{ "ppc476-workaround", optional_argument, NULL, OPTION_PPC476_WORKAROUND },
{ "no-ppc476-workaround", no_argument, NULL, OPTION_NO_PPC476_WORKAROUND },
+ { "no-pic-fixup", no_argument, NULL, OPTION_NO_PICFIXUP },
'
PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
@@ -282,7 +286,8 @@ fi
PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'\
--ppc476-workaround [=pagesize]\n\
Avoid a cache bug on ppc476.\n\
- --no-ppc476-workaround Disable workaround.\n"
+ --no-ppc476-workaround Disable workaround.\n\
+ --no-pic-fixup Don'\''t edit non-pic to pic.\n"
));
'
@@ -336,6 +341,10 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
case OPTION_NO_PPC476_WORKAROUND:
params.ppc476_workaround = 0;
break;
+
+ case OPTION_NO_PICFIXUP:
+ params.pic_fixup = -1;
+ break;
'
# Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation