* [PATCH] Fix place_orphan; add .rela.opd to default ppc64 linker script
@ 2003-08-07 9:15 Jakub Jelinek
2003-08-07 10:24 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2003-08-07 9:15 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
Hi!
cat > test.c <<EOF
extern int bar, baz, f1 (void), f2 (void);
int f3 (void) { return f1 () + 3; }
int f4 (void) { return f2 () + 4; }
EOF
gcc -shared -O2 -fpic -nostdlib -o test.so test.c
results in:
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .hash HASH 00000000000000e8 0000e8 0000b4 04 A 2 0 8
[ 2] .dynsym DYNSYM 00000000000001a0 0001a0 000270 18 A 3 10 8
[ 3] .dynstr STRTAB 0000000000000410 000410 000030 00 A 0 0 1
[ 4] .rela.plt RELA 00000000000004a0 0004a0 000030 18 A 2 c 8
[ 5] .text PROGBITS 00000000000004d0 0004d0 0000f8 00 AX 0 0 4
[ 6] .data PROGBITS 00000000000105c8 0005c8 000000 00 WA 0 0 1
[ 7] .branch_lt PROGBITS 00000000000105c8 0005c8 000000 00 WA 0 0 8
[ 8] .opd PROGBITS 00000000000105c8 0005c8 000030 00 WA 0 0 8
[ 9] .dynamic DYNAMIC 00000000000105f8 0005f8 000130 10 WA 3 0 8
[10] .got PROGBITS 0000000000010728 000728 000008 08 WA 0 0 8
[11] .sbss NOBITS 0000000000010730 000730 000000 00 W 0 0 1
[12] .plt NOBITS 0000000000010730 000730 000048 18 WA 0 0 8
[13] .bss NOBITS 0000000000010778 000730 000000 00 WA 0 0 1
[14] .comment PROGBITS 0000000000000000 000730 000030 00 0 0 1
[15] .rela.dyn RELA 0000000000000440 000440 000060 18 A 2 0 8
[16] .shstrtab STRTAB 0000000000000000 000760 000083 00 0 0 1
[17] .symtab SYMTAB 0000000000000000 000ca8 000300 18 18 16 8
[18] .strtab STRTAB 0000000000000000 000fa8 00004c 00 0 0 1
(see .rela.dyn placement). Although this is not invalid, it makes such libraries
e.g. not prelinkable and is ugly.
The following patch fixes it (well, either hunk of the patch does, but I think both
should be done).
Ok to commit?
2003-08-05 Jakub Jelinek <jakub@redhat.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): If secname
is in the linker script but os->bfd_section is NULL, use
output_prev_sec_find to place it on the right place in the section
list.
* emulparams/elf64ppc.sh (OTHER_GOT_RELOC_SECTIONS): Add .rela.opd.
--- binutils/ld/emulparams/elf64ppc.sh.jj 2003-07-28 10:24:45.000000000 -0400
+++ binutils/ld/emulparams/elf64ppc.sh 2003-08-05 08:35:58.000000000 -0400
@@ -28,7 +28,8 @@ else
.toc 0 : { *(.toc) }"
fi
OTHER_GOT_RELOC_SECTIONS="
- .rela.toc ${RELOCATING-0} : { *(.rela.toc) }"
+ .rela.toc ${RELOCATING-0} : { *(.rela.toc) }
+ .rela.opd ${RELOCATING-0} : { *(.rela.opd) }"
OTHER_READWRITE_SECTIONS="
.toc1 ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.toc1) }
.opd ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { KEEP (*(.opd)) }"
--- binutils/ld/emultempl/elf32.em.jj 2003-08-05 06:59:49.000000000 -0400
+++ binutils/ld/emultempl/elf32.em 2003-08-05 08:27:23.000000000 -0400
@@ -1138,7 +1138,27 @@ gld${EMULATION_NAME}_place_orphan (lang_
{
/* We already have an output section statement with this
name, and its bfd section, if any, has compatible flags. */
- lang_add_section (&os->children, s, os, file);
+ if (os->bfd_section != NULL)
+ lang_add_section (&os->children, s, os, file);
+ else
+ {
+ asection *prev_section = output_prev_sec_find (os);
+ lang_add_section (&os->children, s, os, file);
+ if (prev_section != NULL)
+ {
+ asection *snew = os->bfd_section, **pps;
+
+ /* Unlink the section. */
+ for (pps = &output_bfd->sections; *pps != snew;
+ pps = &(*pps)->next)
+ ;
+ bfd_section_list_remove (output_bfd, pps);
+
+ /* Now tack it on to the "os" section list. */
+ bfd_section_list_insert (output_bfd, &prev_section->next,
+ snew);
+ }
+ }
return TRUE;
}
}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix place_orphan; add .rela.opd to default ppc64 linker script
2003-08-07 9:15 [PATCH] Fix place_orphan; add .rela.opd to default ppc64 linker script Jakub Jelinek
@ 2003-08-07 10:24 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2003-08-07 10:24 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: binutils
On Tue, Aug 05, 2003 at 02:45:59PM +0200, Jakub Jelinek wrote:
> * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): If secname
> is in the linker script but os->bfd_section is NULL, use
> output_prev_sec_find to place it on the right place in the section
> list.
> * emulparams/elf64ppc.sh (OTHER_GOT_RELOC_SECTIONS): Add .rela.opd.
OK. How hard is it to fix prelink so that it doesn't depend on a sorted
section list? If it's too hard, please amend the "This is only
cosmetic" comment I wrote a little later in elf32.em to mention the
prelink requirement.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-07 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-07 9:15 [PATCH] Fix place_orphan; add .rela.opd to default ppc64 linker script Jakub Jelinek
2003-08-07 10:24 ` Alan Modra
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).