From: Daniel Jacobowitz <drow@false.org>
To: binutils@sourceware.org
Subject: Fix arm-symbianelf data segment relocs
Date: Mon, 28 Apr 2008 23:07:00 -0000 [thread overview]
Message-ID: <20080428203856.GA15792@caradoc.them.org> (raw)
This patch swaps the initialization order of text_index_section
and data_index_section. This is needed because
_bfd_elf_link_omit_section_dynsym checks text_index_section; once
text_index_section is set and data_index_section is still NULL, it
will request we omit dynsyms for all sections besides
text_index_section. So we have never set data_index_section.
This patch allows arm-none-symbianelf-ld to generate R_ARM_RELATIVE
relocations against .data. I tried to enable the ELF-specific tests
in the ld testsuite for symbianelf and add one for this, but failed -
the results are very atypical because output files are not D_PAGED.
I did add one test for this specific problem. But that required
patching objdump; .rel.dyn on this target is not SEC_LOAD. I
think this change is safe but I'd appreciate review.
Tested on arm-none-symbianelf where it brings GDB test results
back from the grave. OK to commit?
--
Daniel Jacobowitz
CodeSourcery
2008-04-28 Daniel Jacobowitz <dan@codesourcery.com>
* elf.c (_bfd_elf_get_dynamic_reloc_upper_bound)
(_bfd_elf_canonicalize_dynamic_reloc): Find dynamic relocations
even if they are not loaded.
* elflink.c (_bfd_elf_init_2_index_sections): Set data_index_section
first.
2008-04-28 Daniel Jacobowitz <dan@codesourcery.com>
* ld-arm/symbian-seg1.s, ld-arm/symbian-seg1.d: New files.
* ld-arm/arm-elf.exp: Run symbian-seg1.
Index: ld/testsuite/ld-arm/symbian-seg1.d
===================================================================
--- ld/testsuite/ld-arm/symbian-seg1.d (revision 0)
+++ ld/testsuite/ld-arm/symbian-seg1.d (revision 0)
@@ -0,0 +1,8 @@
+#source: symbian-seg1.s
+#ld: -Ttext 0x10000 -Tdata 0x400000
+#objdump: -dR
+#...
+ +10000: 00400000 .word 0x00400000
+ +10000: R_ARM_RELATIVE .data
+ +10004: 00010008 .word 0x00010008
+ +10004: R_ARM_RELATIVE .text
Index: ld/testsuite/ld-arm/symbian-seg1.s
===================================================================
--- ld/testsuite/ld-arm/symbian-seg1.s (revision 0)
+++ ld/testsuite/ld-arm/symbian-seg1.s (revision 0)
@@ -0,0 +1,13 @@
+ .text
+ .globl _start
+_start:
+ .word datavar
+ .word rodatavar
+
+ .section ".rodata", "a"
+rodatavar:
+ .word 0
+
+ .section ".data", "aw"
+datavar:
+ .word 0
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
--- ld/testsuite/ld-arm/arm-elf.exp (revision 206063)
+++ ld/testsuite/ld-arm/arm-elf.exp (working copy)
@@ -47,6 +47,10 @@ if {[istarget "arm-*-vxworks"]} {
run_dump_test "emit-relocs1-vxworks"
}
+if { [istarget "arm*-*-symbianelf*"] } {
+ run_dump_test "symbian-seg1"
+}
+
# Exclude non-ARM-ELF targets.
if { ![is_elf_format] || ![istarget "arm*-*-*"] } {
Index: bfd/elf.c
===================================================================
--- bfd/elf.c (revision 206063)
+++ bfd/elf.c (working copy)
@@ -6577,8 +6577,7 @@ _bfd_elf_get_dynamic_reloc_upper_bound (
ret = sizeof (arelent *);
for (s = abfd->sections; s != NULL; s = s->next)
- if ((s->flags & SEC_LOAD) != 0
- && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+ if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
&& (elf_section_data (s)->this_hdr.sh_type == SHT_REL
|| elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
ret += ((s->size / elf_section_data (s)->this_hdr.sh_entsize)
@@ -6614,8 +6613,7 @@ _bfd_elf_canonicalize_dynamic_reloc (bfd
ret = 0;
for (s = abfd->sections; s != NULL; s = s->next)
{
- if ((s->flags & SEC_LOAD) != 0
- && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+ if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
&& (elf_section_data (s)->this_hdr.sh_type == SHT_REL
|| elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
{
Index: bfd/elflink.c
===================================================================
--- bfd/elflink.c (revision 206063)
+++ bfd/elflink.c (working copy)
@@ -6136,20 +6136,22 @@ _bfd_elf_init_2_index_sections (bfd *out
{
asection *s;
+ /* Data first, since setting text_index_section changes
+ _bfd_elf_link_omit_section_dynsym. */
for (s = output_bfd->sections; s != NULL; s = s->next)
- if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
- == (SEC_ALLOC | SEC_READONLY))
+ if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
&& !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
{
- elf_hash_table (info)->text_index_section = s;
+ elf_hash_table (info)->data_index_section = s;
break;
}
for (s = output_bfd->sections; s != NULL; s = s->next)
- if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
+ if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
+ == (SEC_ALLOC | SEC_READONLY))
&& !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
{
- elf_hash_table (info)->data_index_section = s;
+ elf_hash_table (info)->text_index_section = s;
break;
}
next reply other threads:[~2008-04-28 20:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 23:07 Daniel Jacobowitz [this message]
2008-04-29 9:45 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080428203856.GA15792@caradoc.them.org \
--to=drow@false.org \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).