[PATCH] Fix yet another bug introduced with the SIZEOF .tbss changes
Jakub Jelinek
jakub@redhat.com
Sun Apr 18 21:06:00 GMT 2004
Hi!
If .tbss section is followed by a symbol assignment (PROVIDES or normal),
it is set incorrectly.
This leads to segfaults on ia64 of lots of statically linked binaries,
e.g. ldconfig has without this patch:
[16] .tbss NOBITS 6000000000006d10 106d10 000030 00 WAT 0 0 8
[17] .init_array INIT_ARRAY 6000000000006d10 106d10 000018 00 WA 0 0 8
[18] .fini_array FINI_ARRAY 6000000000006d28 106d28 000008 00 WA 0 0 8
[19] .ctors PROGBITS 6000000000006d30 106d30 000010 00 WA 0 0 8
1734: 6000000000006d30 0 NOTYPE GLOBAL DEFAULT ABS __fini_array_end
2227: 6000000000006d28 0 NOTYPE GLOBAL DEFAULT ABS __fini_array_start
2290: 6000000000006d28 0 NOTYPE GLOBAL DEFAULT ABS __init_array_end
2405: 6000000000006d40 0 NOTYPE GLOBAL DEFAULT ABS __preinit_array_end
2589: 6000000000006d40 0 NOTYPE GLOBAL DEFAULT ABS __init_array_start
2670: 6000000000006d40 0 NOTYPE GLOBAL DEFAULT ABS __preinit_array_start
See that __init_array_start is > __init_array_end, while it should be
0x60{11}6d10.
Ok to commit?
2004-04-18 Jakub Jelinek <jakub@redhat.com>
* ldlang.c (lang_do_assignments_1): Handle .tbss output section
specially.
--- ld/ldlang.c.jj 2004-04-18 21:10:15.150860320 +0200
+++ ld/ldlang.c 2004-04-18 21:23:39.834650508 +0200
@@ -3350,9 +3350,11 @@ lang_do_assignments_1
{
dot = os->bfd_section->vma;
lang_do_assignments_1 (os->children.head, os, os->fill, dot);
- dot = (os->bfd_section->vma
- + TO_ADDR (os->bfd_section->_raw_size));
-
+ /* .tbss sections effectively have zero size. */
+ if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0
+ || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0
+ || link_info.relocatable)
+ dot += TO_ADDR (os->bfd_section->_raw_size);
}
if (os->load_base)
{
Jakub
More information about the Binutils
mailing list