This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] bfd/elflink.c create_got_section fix for rel(a).got
- From: Andreas Tobler <andreast-list at fgznet dot ch>
- To: binutils at sourceware dot org
- Date: Wed, 09 Nov 2011 09:22:24 +0100
- Subject: [patch] bfd/elflink.c create_got_section fix for rel(a).got
All,
The patch below fixes my upcoming powerpc*-freebsd* target when I try to
link against shared libraries.
The problem is the following when I run the test suite I get 'could not
read symbols' 'No error/Format not recognized' when the test tries to
'link in' a shared library. The 'No error' happens in case of a
self-built library, the 'Format not recognized' happens for example for
libc.so
The first file of the link command contains a rela.got section:
readelf -t /usr/lib/crt1.o | grep got
[ 6] .got
[ 7] .rela.got
In my understanding with the existing code ld jumps out with NULL as
soon as ld sees a rel(a).got section. And this leaves my shared library
unrecognized.
I was in contact with Alan and he pointed me to the below solution.
s/bfd_make_section_with_flags/bfd_make_section_anyway_with_flags
The patch was tested on powerpc64-freebsd, x86_64-freebsd and on a
x86_64 GNU/Linux system.
Is this patch ok for trunk? Afaik it also happens on 2.21.
TIA,
Andreas
2011-11-09 Andreas Tobler <andreast@fgznet.ch>
* elflink.c (_bfd_elf_create_got_section): Replace
bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.429
diff -u -r1.429 elflink.c
--- bfd/elflink.c 8 Nov 2011 13:49:11 -0000 1.429
+++ bfd/elflink.c 9 Nov 2011 08:04:43 -0000
@@ -110,17 +110,17 @@
flags = bed->dynamic_sec_flags;
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.got" : ".rel.got"),
- (bed->dynamic_sec_flags
- | SEC_READONLY));
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.got" : ".rel.got"),
+ (bed->dynamic_sec_flags
+ | SEC_READONLY));
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
htab->srelgot = s;
- s = bfd_make_section_with_flags (abfd, ".got", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -128,7 +128,7 @@
if (bed->want_got_plt)
{
- s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))