* elf.c (map_sections_to_segments): Ignore .tbss sections for
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 5 Mar 2004 11:26:05 +0000 (11:26 +0000)
committerNathan Sidwell <nathan@codesourcery.com>
Fri, 5 Mar 2004 11:26:05 +0000 (11:26 +0000)
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.

12 files changed:
bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/ldlang.c
ld/testsuite/ChangeLog
ld/testsuite/ld-scripts/size-1.d [new file with mode: 0644]
ld/testsuite/ld-scripts/size-1.s [new file with mode: 0644]
ld/testsuite/ld-scripts/size-1.t [new file with mode: 0644]
ld/testsuite/ld-scripts/size-2.d [new file with mode: 0644]
ld/testsuite/ld-scripts/size-2.s [new file with mode: 0644]
ld/testsuite/ld-scripts/size-2.t [new file with mode: 0644]
ld/testsuite/ld-scripts/size.exp [new file with mode: 0644]

index e0da01f36cb5a39a6d725fe7175069ac78b068a9..c16e003abc5e106a2d8c5a39bccc7115276a884e 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-05  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * elf.c (map_sections_to_segments): Ignore .tbss sections for
+       layout purposes.
+
 2004-03-03  Alexandre Oliva  <aoliva@redhat.com>
 
        * elflink.c (bfd_elf_record_link_assignment): Mark undefweak and
index 5e31f8935832c05c06453e64e89c0b7ab43014e1..33b58f5bead8ee9cf5247bd208c2e351e63ad777 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3360,7 +3360,9 @@ map_sections_to_segments (bfd *abfd)
        {
          if ((hdr->flags & SEC_READONLY) == 0)
            writable = TRUE;
-         last_hdr = hdr;
+         /* Ignore .tbss section for segment layout purposes.  */
+         if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL)
+           last_hdr = hdr;
          continue;
        }
 
index 81ebfa1d9ae0cb800ee252e59fbbe9d5c834bdad..38ac4fed80f63fac3f065b8216a88c181260aa0a 100644 (file)
@@ -1,3 +1,10 @@
+2004-03-05  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * 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.
+
 2004-03-01  Andreas Schwab  <schwab@suse.de>
 
        * ld.texinfo (Options): Fix example for --wrap.
index 4244c9276afea0627ec1bfed9f5f7ed86a3add5f..3855998c07301ecf5e1b821196b3306af2d7821e 100644 (file)
@@ -1101,10 +1101,6 @@ lang_add_section (lang_statement_list_type *ptr,
          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)
@@ -2770,8 +2766,11 @@ size_input_section (lang_statement_union_type **this_ptr,
 }
 
 #define IGNORE_SECTION(bfd, s) \
-  (((bfd_get_section_flags (bfd, s) & (SEC_ALLOC | SEC_NEVER_LOAD))    \
-    != SEC_ALLOC)                                                      \
+  (((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
@@ -3021,15 +3020,17 @@ lang_size_sections_1
 
            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);
+           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 5a33cfff6e31925c91a7687108791d9d6537e815..18c66f46123a3af20cf90133987641f8d7b49abe 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-05  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * ld-scripts/size.exp: New.
+       * ld-scripts/size-[12].{d,s,t}: New.
+
 2004-03-01  Richard Sandiford  <rsandifo@redhat.com>
 
        * ld-frv/fr450-link[abc].s, fr450-link.d: New test.
diff --git a/ld/testsuite/ld-scripts/size-1.d b/ld/testsuite/ld-scripts/size-1.d
new file mode 100644 (file)
index 0000000..667f531
--- /dev/null
@@ -0,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)?                             ....            
diff --git a/ld/testsuite/ld-scripts/size-1.s b/ld/testsuite/ld-scripts/size-1.s
new file mode 100644 (file)
index 0000000..53721fa
--- /dev/null
@@ -0,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
diff --git a/ld/testsuite/ld-scripts/size-1.t b/ld/testsuite/ld-scripts/size-1.t
new file mode 100644 (file)
index 0000000..8582840
--- /dev/null
@@ -0,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))
+  }
+}
diff --git a/ld/testsuite/ld-scripts/size-2.d b/ld/testsuite/ld-scripts/size-2.d
new file mode 100644 (file)
index 0000000..3cbfb44
--- /dev/null
@@ -0,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 
diff --git a/ld/testsuite/ld-scripts/size-2.s b/ld/testsuite/ld-scripts/size-2.s
new file mode 100644 (file)
index 0000000..eba3224
--- /dev/null
@@ -0,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
diff --git a/ld/testsuite/ld-scripts/size-2.t b/ld/testsuite/ld-scripts/size-2.t
new file mode 100644 (file)
index 0000000..3549321
--- /dev/null
@@ -0,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
+}
diff --git a/ld/testsuite/ld-scripts/size.exp b/ld/testsuite/ld-scripts/size.exp
new file mode 100644 (file)
index 0000000..5fff2bd
--- /dev/null
@@ -0,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
+}
This page took 0.055142 seconds and 4 git commands to generate.