This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: SIZEOF and .tbss
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 04 Mar 2004 15:35:03 +0000
- Subject: Re: SIZEOF and .tbss
- Organization: Codesourcery LLC
- References: <4039E6E3.4080507@codesourcery.com> <m3llmiw6s8.fsf@redhat.com>
Nick,
This patch implements that functionality in a different manner. Rather than
lie about .tbss's size, I tweak the couple of places that need to know
it can be ignored for layout purposes.
It appears that there are now some new failures in the linker
testsuite with this patch applied:
This patch adds the equivalent bit into elf.c's segment mapping. With
this patch I find the linkers testsuite has the same failures as without
the patch (on i686-pc-linux-gnu). ok?
I'll investigate those failures I'm seeing -- it might be related
to me using a gcc-3.4-pre compiler. I'd understand if you'd like to
hold off this patch until these other failures are resolved.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-03-04 Nathan Sidwell <nathan@codesourcery.com>
* elf.c (map_sections_to_segments): Ignore .tbss sections for
layout purposes.
* ldlang.c (lang_add_section): Don't force SEC_LOAD on
SEC_THREAD_LOCAL.
(IGNORE_SECTION): Ignore .tbss sections too.
(lang_size_sections_1): .tbss sections do not advance dot.
* ld-scripts/size.exp: New.
* ld-scripts/size-[12].{d,s,t}: New.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.217
diff -c -3 -p -r1.217 elf.c
*** bfd/elf.c 13 Feb 2004 14:58:58 -0000 1.217
--- bfd/elf.c 4 Mar 2004 15:27:11 -0000
*************** map_sections_to_segments (bfd *abfd)
*** 3360,3366 ****
{
if ((hdr->flags & SEC_READONLY) == 0)
writable = TRUE;
! last_hdr = hdr;
continue;
}
--- 3360,3368 ----
{
if ((hdr->flags & SEC_READONLY) == 0)
writable = TRUE;
! /* Ignore .tbss section for segment layout purposes. */
! if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL)
! last_hdr = hdr;
continue;
}
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.139
diff -c -3 -p -r1.139 ldlang.c
*** ld/ldlang.c 23 Feb 2004 19:41:53 -0000 1.139
--- ld/ldlang.c 4 Mar 2004 15:27:34 -0000
*************** lang_add_section (lang_statement_list_ty
*** 1101,1110 ****
flags &= ~ (SEC_MERGE | SEC_STRINGS);
}
- /* For now make .tbss normal section. */
- if ((flags & SEC_THREAD_LOCAL) && ! link_info.relocatable)
- flags |= SEC_LOAD;
-
section->output_section->flags |= flags;
if (flags & SEC_MERGE)
--- 1101,1106 ----
*************** size_input_section (lang_statement_union
*** 2770,2777 ****
}
#define IGNORE_SECTION(bfd, s) \
! (((bfd_get_section_flags (bfd, s) & (SEC_ALLOC | SEC_NEVER_LOAD)) \
! != SEC_ALLOC) \
|| bfd_section_size (bfd, s) == 0)
/* Check to see if any allocated sections overlap with other allocated
--- 2766,2776 ----
}
#define IGNORE_SECTION(bfd, s) \
! (((bfd_get_section_flags (bfd, s) & SEC_THREAD_LOCAL) \
! ? ((bfd_get_section_flags (bfd, s) & (SEC_LOAD | SEC_NEVER_LOAD)) \
! != SEC_LOAD) \
! : ((bfd_get_section_flags (bfd, s) & (SEC_ALLOC | SEC_NEVER_LOAD)) \
! != SEC_ALLOC)) \
|| bfd_section_size (bfd, s) == 0)
/* Check to see if any allocated sections overlap with other allocated
*************** lang_size_sections_1
*** 3021,3035 ****
if (bfd_is_abs_section (os->bfd_section))
ASSERT (after == os->bfd_section->vma);
- else if ((os->bfd_section->flags & SEC_HAS_CONTENTS) == 0
- && (os->bfd_section->flags & SEC_THREAD_LOCAL)
- && ! link_info.relocatable)
- os->bfd_section->_raw_size = 0;
else
os->bfd_section->_raw_size
= TO_SIZE (after - os->bfd_section->vma);
! dot = os->bfd_section->vma + TO_ADDR (os->bfd_section->_raw_size);
os->processed = 1;
if (os->update_dot_tree != 0)
--- 3020,3036 ----
if (bfd_is_abs_section (os->bfd_section))
ASSERT (after == os->bfd_section->vma);
else
os->bfd_section->_raw_size
= TO_SIZE (after - os->bfd_section->vma);
! dot = os->bfd_section->vma;
! /* .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);
!
os->processed = 1;
if (os->update_dot_tree != 0)
Index: ld/testsuite/ld-scripts/size-1.d
===================================================================
RCS file: ld/testsuite/ld-scripts/size-1.d
diff -N ld/testsuite/ld-scripts/size-1.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-1.d 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,16 ----
+ #source: size-1.s
+ #ld: -T size-1.t
+ #objdump: -s
+
+ .*: file format .*
+
+ Contents of section \.text:
+ 0+00 (01)?000000(01)? (02)?000000(02)? ........
+ Contents of section \.data:
+ 0+08 (03)?000000(03)? (04)?000000(04)? (05)?000000(05)? ............
+ Contents of section \.tdata:
+ 0+24 (06)?000000 07000000 08000000 09000000 ................
+ 0+34 (0a)?000000 ....
+ Contents of section \.map:
+ 0+38 (08)?000000(08)? (0c)?000000(0c)? (10)?000000(10)? (14)?000000(14)? ................
+ 0+48 (18)?000000(18)? ....
Index: ld/testsuite/ld-scripts/size-1.s
===================================================================
RCS file: ld/testsuite/ld-scripts/size-1.s
diff -N ld/testsuite/ld-scripts/size-1.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-1.s 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,15 ----
+ .section .text,"ax",@progbits
+ .long 1,2
+
+ .section .data,"aw",@progbits
+ .long 3,4,5
+
+ .section .bss,"aw",@nobits
+ .long 0,0,0,0
+
+ # thread local storage sections
+ .section .tdata,"awT",@progbits
+ .long 6,7,8,9,10
+
+ .section .tbss,"awT",@nobits
+ .long 0,0,0,0,0,0
Index: ld/testsuite/ld-scripts/size-1.t
===================================================================
RCS file: ld/testsuite/ld-scripts/size-1.t
diff -N ld/testsuite/ld-scripts/size-1.t
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-1.t 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,15 ----
+ SECTIONS
+ {
+ .text : { *(.text) }
+ .data : { *(.data) }
+ .bss : { *(.bss) }
+ .tdata : { *(.tdata) }
+ .tbss : { *(.tbss) }
+ .map : {
+ LONG (SIZEOF (.text))
+ LONG (SIZEOF (.data))
+ LONG (SIZEOF (.bss))
+ LONG (SIZEOF (.tdata))
+ LONG (SIZEOF (.tbss))
+ }
+ }
Index: ld/testsuite/ld-scripts/size-2.d
===================================================================
RCS file: ld/testsuite/ld-scripts/size-2.d
diff -N ld/testsuite/ld-scripts/size-2.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-2.d 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,20 ----
+ #source: size-2.s
+ #ld: -T size-2.t
+ #readelf: -l
+
+ #...
+ Program Headers:
+ Type Offset VirtAddr PhysAddr
+ FileSiz MemSiz Flags Align
+ PHDR 0x[0-9a-f]+ 0x0+0000 0x0+0000
+ 0x[0-9a-f]+ 0x[0-9a-f]+ R .
+ LOAD 0x[0-9a-f]+ 0x0+0000 0x0+0000
+ 0x0+0030 0x0+0030 R [0-9a-f]+
+ TLS 0x[0-9a-f]+ 0x0+0008 0x0+0008
+ 0x0+0014 0x0+002c R [0-9a-f]+
+
+ Section to Segment mapping:
+ Segment Sections...
+ 00 \.text \.tdata \.tbss \.map
+ 01 \.text \.tdata \.map
+ 02 \.tdata \.tbss \.map
Index: ld/testsuite/ld-scripts/size-2.s
===================================================================
RCS file: ld/testsuite/ld-scripts/size-2.s
diff -N ld/testsuite/ld-scripts/size-2.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-2.s 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,9 ----
+ .section .text,"ax",@progbits
+ .long 1,2
+
+ # thread local storage sections
+ .section .tdata,"awT",@progbits
+ .long 6,7,8,9,10
+
+ .section .tbss,"awT",@nobits
+ .long 0,0,0,0,0,0
Index: ld/testsuite/ld-scripts/size-2.t
===================================================================
RCS file: ld/testsuite/ld-scripts/size-2.t
diff -N ld/testsuite/ld-scripts/size-2.t
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size-2.t 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,21 ----
+ PHDRS
+ {
+ header PT_PHDR FILEHDR PHDRS ;
+
+ image PT_LOAD FLAGS (4);
+ tls PT_TLS FLAGS (4);
+
+ }
+ SECTIONS
+ {
+ .text : { *(.text) } :image
+ .tdata : { *(.tdata) } :image :tls
+ .tbss : { *(.tbss) } :image : tls
+ .map : {
+ LONG (SIZEOF (.text))
+ LONG (SIZEOF (.data))
+ LONG (SIZEOF (.bss))
+ LONG (SIZEOF (.tdata))
+ LONG (SIZEOF (.tbss))
+ } :image
+ }
Index: ld/testsuite/ld-scripts/size.exp
===================================================================
RCS file: ld/testsuite/ld-scripts/size.exp
diff -N ld/testsuite/ld-scripts/size.exp
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/size.exp 4 Mar 2004 15:27:39 -0000
***************
*** 0 ****
--- 1,23 ----
+ # Expect script for SIZEOF tests
+ # Copyright (C) 2004 Free Software Foundation
+ #
+ # This file is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #
+
+ run_dump_test size-1
+
+ if { [istarget "*-*-elf*"] } {
+ run_dump_test size-2
+ }