This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Patch for ppc _SDA_BASE_ value
- To: GNU binutils <binutils at sourceware dot cygnus dot com>
- Subject: Patch for ppc _SDA_BASE_ value
- From: Momchil Velikov <velco at fadata dot bg>
- Date: Thu, 23 Mar 2000 00:45:10 +0200
Hi,
Please, consider the attached patch. It adds near the
beginning of ppc_elf_relocate_section() a few lines, which
adjust the values of _SDA_BASE_ and _SDA2_BASE_ if these symbols
are not absolute (i.e. they are not set by a linker script, is that
correct?).
Also, the checks for the output section names are removed.
Note, that I have not yet actually tested how the resulting executable
works with
these changes applied to the BFD/ld, just examined some objdump's
and map files. Expect more info during the weekend.
Regards,
-velco
--- elf32-ppc.c.orig Wed Mar 22 22:26:06 2000
+++ elf32-ppc.c Thu Mar 23 00:20:58 2000
@@ -2934,6 +2934,24 @@
if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
ppc_elf_howto_init ();
+ /* Make sure _SDA_BASE_ and _SDA2_BASE_ are at offset <= 32768 from the
+ beginning of the respective output section. */
+ if (sdata
+ && sdata->sym_hash->root.u.def.section
+ && ( sdata->sym_hash->root.u.def.value
+ + sdata->sym_hash->root.u.def.section->output_offset ) > 32768)
+ {
+ sdata->sym_hash->root.u.def.value -= sdata->sym_hash->root.u.def.section->output_offset;
+ }
+
+ if (sdata2
+ && sdata2->sym_hash->root.u.def.section
+ && ( sdata2->sym_hash->root.u.def.value
+ + sdata2->sym_hash->root.u.def.section->output_offset ) > 32768)
+ {
+ sdata2->sym_hash->root.u.def.value -= sdata2->sym_hash->root.u.def.section->output_offset;
+ }
+
local_got_offsets = elf_local_got_offsets (input_bfd);
splt = sgot = NULL;
@@ -3480,50 +3498,17 @@
/* relocate against _SDA_BASE_ */
case (int)R_PPC_SDAREL16:
- {
- const char *name;
-
- BFD_ASSERT (sec != (asection *)0);
- name = bfd_get_section_name (abfd, sec->output_section);
- if (strcmp (name, ".sdata") != 0
- && strcmp (name, ".sbss") != 0)
- {
- (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
- bfd_get_filename (input_bfd),
- sym_name,
- ppc_elf_howto_table[ (int)r_type ]->name,
- name);
- }
- addend -= (sdata->sym_hash->root.u.def.value
- + sdata->sym_hash->root.u.def.section->output_section->vma
- + sdata->sym_hash->root.u.def.section->output_offset);
- }
+ addend -= (sdata->sym_hash->root.u.def.value
+ + sdata->sym_hash->root.u.def.section->output_section->vma
+ + sdata->sym_hash->root.u.def.section->output_offset);
break;
/* relocate against _SDA2_BASE_ */
case (int)R_PPC_EMB_SDA2REL:
- {
- const char *name;
-
- BFD_ASSERT (sec != (asection *)0);
- name = bfd_get_section_name (abfd, sec->output_section);
- if (strcmp (name, ".sdata2") != 0 && strcmp (name, ".sbss2") != 0)
- {
- (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
- bfd_get_filename (input_bfd),
- sym_name,
- ppc_elf_howto_table[ (int)r_type ]->name,
- name);
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
- }
- addend -= (sdata2->sym_hash->root.u.def.value
- + sdata2->sym_hash->root.u.def.section->output_section->vma
- + sdata2->sym_hash->root.u.def.section->output_offset);
- }
+ addend -= (sdata2->sym_hash->root.u.def.value
+ + sdata2->sym_hash->root.u.def.section->output_section->vma
+ + sdata2->sym_hash->root.u.def.section->output_offset);
break;