aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2006-09-27 04:18:16 +0000
committerH.J. Lu <hjl.tools@gmail.com>2006-09-27 04:18:16 +0000
commit49c13adb16c432e9d04770f7c6b8348e31bb1df1 (patch)
tree4169c5e520d6c3228abd35ebf85228ca9cda9375
parentf36b9bcd93570f658ebfe3c6946409eed2533e6d (diff)
downloadgdb-49c13adb16c432e9d04770f7c6b8348e31bb1df1.zip
gdb-49c13adb16c432e9d04770f7c6b8348e31bb1df1.tar.gz
gdb-49c13adb16c432e9d04770f7c6b8348e31bb1df1.tar.bz2
bfd/
2006-09-26 H.J. Lu <hongjiu.lu@intel.com> PR ld/3223 PR ld/3267 * elf.c (assign_file_positions_for_non_load_sections): Don't warn zero size allocated sections. ld/ 2006-09-26 H.J. Lu <hongjiu.lu@intel.com> PR ld/3223 PR ld/3267 * ld.texinfo: Updated Output Section Discarding. * ldlang.h (lang_output_section_statement_type): Add section_relative_symbol. * ldlang.c (strip_excluded_output_sections): Don't strip a section with a symbol relative to it. (lang_size_sections_1): Mark if an output section has a symbol symbol relative to it. ld/testsuite/ 2006-09-26 H.J. Lu <hongjiu.lu@intel.com> PR ld/3223 PR ld/3267 * ld-scripts/empty-address-1.d: New file. * ld-scripts/empty-address-1.s: Likewise. * ld-scripts/empty-address-1.t: Likewise. * ld-scripts/empty-address-2.s: Likewise. * ld-scripts/empty-address-2a.d: Likewise. * ld-scripts/empty-address-2a.t: Likewise. * ld-scripts/empty-address-2b.d: Likewise. * ld-scripts/empty-address-2b.t: Likewise. * ld-scripts/empty-address-3.s: Likewise. * ld-scripts/empty-address-3a.d: Likewise. * ld-scripts/empty-address-3a.t: Likewise. * ld-scripts/empty-address-3b.d: Likewise. * ld-scripts/empty-address-3b.t: Likewise. * ld-scripts/empty-address-3c.d: Likewise. * ld-scripts/empty-address-3c.t: Likewise. * ld-scripts/empty-address.exp: Likewise.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c13
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/ld.texinfo4
-rw-r--r--ld/ldlang.c11
-rw-r--r--ld/ldlang.h3
-rw-r--r--ld/testsuite/ChangeLog21
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2a.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2a.t7
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2b.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2b.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3a.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3a.t10
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3b.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3b.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3c.d10
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3c.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address.exp25
23 files changed, 215 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e8bf78b..a241894 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3223
+ PR ld/3267
+ * elf.c (assign_file_positions_for_non_load_sections): Don't
+ warn zero size allocated sections.
+
2006-09-27 Alan Modra <amodra@bigpond.net.au>
* elf32-score.c (_bfd_score_elf_relocate_section): Move assignment
diff --git a/bfd/elf.c b/bfd/elf.c
index 87c3cc7..ab23a19 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4662,12 +4662,13 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
hdr->sh_offset = hdr->bfd_section->filepos;
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
- ((*_bfd_error_handler)
- (_("%B: warning: allocated section `%s' not in segment"),
- abfd,
- (hdr->bfd_section == NULL
- ? "*unknown*"
- : hdr->bfd_section->name)));
+ if (hdr->sh_size != 0)
+ ((*_bfd_error_handler)
+ (_("%B: warning: allocated section `%s' not in segment"),
+ abfd,
+ (hdr->bfd_section == NULL
+ ? "*unknown*"
+ : hdr->bfd_section->name)));
if ((abfd->flags & D_PAGED) != 0)
off += vma_page_aligned_bias (hdr->sh_addr, off,
bed->maxpagesize);
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 9fd4df0..fee4beb 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,16 @@
+2006-09-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3223
+ PR ld/3267
+ * ld.texinfo: Updated Output Section Discarding.
+
+ * ldlang.h (lang_output_section_statement_type): Add
+ section_relative_symbol.
+ * ldlang.c (strip_excluded_output_sections): Don't strip a
+ section with a symbol relative to it.
+ (lang_size_sections_1): Mark if an output section has a symbol
+ symbol relative to it.
+
2006-09-25 Bob Wilson <bob.wilson@acm.org>
* ld.texinfo (Options): Update description of local symbols for -X.
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 5ab4e3f..6835147 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -3688,7 +3688,7 @@ The linker will not create output section which do not have any
contents. This is for convenience when referring to input sections that
may or may not be present in any of the input files. For example:
@smallexample
-.foo @{ *(.foo) @}
+.foo : @{ *(.foo) @}
@end smallexample
@noindent
will only create a @samp{.foo} section in the output file if there is a
@@ -3697,6 +3697,8 @@ will only create a @samp{.foo} section in the output file if there is a
If you use anything other than an input section description as an output
section command, such as a symbol assignment, then the output section
will always be created, even if there are no matching input sections.
+When a section is discarded, its address (@xref{Output Section Address})
+will also be ignored.
@cindex /DISCARD/
The special output section name @samp{/DISCARD/} may be used to discard
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8b6cbd2..4ce3c93 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3342,6 +3342,7 @@ strip_excluded_output_sections (void)
continue;
exclude = (output_section->rawsize == 0
+ && !os->section_relative_symbol
&& (output_section->flags & SEC_KEEP) == 0
&& !bfd_section_removed_from_list (output_bfd,
output_section));
@@ -4629,11 +4630,19 @@ lang_size_sections_1
case lang_assignment_statement_enum:
{
bfd_vma newdot = dot;
+ etree_type *tree = s->assignment_statement.exp;
- exp_fold_tree (s->assignment_statement.exp,
+ exp_fold_tree (tree,
output_section_statement->bfd_section,
&newdot);
+ /* This symbol is relative to this section. */
+ if ((tree->type.node_class == etree_provided
+ || tree->type.node_class == etree_assign)
+ && (tree->assign.dst [0] != '.'
+ || tree->assign.dst [1] != '\0'))
+ output_section_statement->section_relative_symbol = 1;
+
if (!output_section_statement->ignored)
{
if (output_section_statement == abs_output_section)
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 6106cea..99b786d 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -153,7 +153,10 @@ typedef struct lang_output_section_statement_struct
unsigned int processed_vma : 1;
unsigned int processed_lma : 1;
unsigned int all_input_readonly : 1;
+ /* If this section should be ignored. */
unsigned int ignored : 1;
+ /* If there is a symbol relative to this section. */
+ unsigned int section_relative_symbol : 1;
} lang_output_section_statement_type;
typedef struct
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index fd9f422..0cf9890 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,24 @@
+2006-09-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3223
+ PR ld/3267
+ * ld-scripts/empty-address-1.d: New file.
+ * ld-scripts/empty-address-1.s: Likewise.
+ * ld-scripts/empty-address-1.t: Likewise.
+ * ld-scripts/empty-address-2.s: Likewise.
+ * ld-scripts/empty-address-2a.d: Likewise.
+ * ld-scripts/empty-address-2a.t: Likewise.
+ * ld-scripts/empty-address-2b.d: Likewise.
+ * ld-scripts/empty-address-2b.t: Likewise.
+ * ld-scripts/empty-address-3.s: Likewise.
+ * ld-scripts/empty-address-3a.d: Likewise.
+ * ld-scripts/empty-address-3a.t: Likewise.
+ * ld-scripts/empty-address-3b.d: Likewise.
+ * ld-scripts/empty-address-3b.t: Likewise.
+ * ld-scripts/empty-address-3c.d: Likewise.
+ * ld-scripts/empty-address-3c.t: Likewise.
+ * ld-scripts/empty-address.exp: Likewise.
+
2006-09-21 Andreas Schwab <schwab@suse.de>
* ld-m68k/plt1-68020.d: Fix patterns to match also for 64-bit
diff --git a/ld/testsuite/ld-scripts/empty-address-1.d b/ld/testsuite/ld-scripts/empty-address-1.d
new file mode 100644
index 0000000..8b13014
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-1.d
@@ -0,0 +1,8 @@
+#ld: -T empty-address-1.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+2000000 A __data_end
+0+2000000 D __data_start
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-1.s b/ld/testsuite/ld-scripts/empty-address-1.s
new file mode 100644
index 0000000..c5cc1a5
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-1.s
@@ -0,0 +1,5 @@
+ .text
+ .global _start
+_start:
+ .long __data_start
+ .long __data_end
diff --git a/ld/testsuite/ld-scripts/empty-address-1.t b/ld/testsuite/ld-scripts/empty-address-1.t
new file mode 100644
index 0000000..57a8bed
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-1.t
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x0000000: { *(.text) }
+ .data 0x2000000:
+ {
+ __data_start = . ;
+ *(.data)
+ }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-2.s b/ld/testsuite/ld-scripts/empty-address-2.s
new file mode 100644
index 0000000..79f58ea
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2.s
@@ -0,0 +1,5 @@
+ .text
+ .global _start
+_start:
+ .long __data_end
+ .p2align 4
diff --git a/ld/testsuite/ld-scripts/empty-address-2a.d b/ld/testsuite/ld-scripts/empty-address-2a.d
new file mode 100644
index 0000000..d831d5f
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2a.d
@@ -0,0 +1,8 @@
+#source: empty-address-2.s
+#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2a.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-2a.t b/ld/testsuite/ld-scripts/empty-address-2a.t
new file mode 100644
index 0000000..6a40ad8
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2a.t
@@ -0,0 +1,7 @@
+SECTIONS
+{
+ .text : { *(.text) }
+ .data : { *(.data) }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-2b.d b/ld/testsuite/ld-scripts/empty-address-2b.d
new file mode 100644
index 0000000..514fd68
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2b.d
@@ -0,0 +1,8 @@
+#source: empty-address-2.s
+#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2b.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-2b.t b/ld/testsuite/ld-scripts/empty-address-2b.t
new file mode 100644
index 0000000..dcf264f
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2b.t
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x0000000: { *(.text) }
+ .data :
+ {
+ PROVIDE (__data_start = .);
+ *(.data)
+ }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-3.s b/ld/testsuite/ld-scripts/empty-address-3.s
new file mode 100644
index 0000000..6b07dd4
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3.s
@@ -0,0 +1,5 @@
+ .text
+ .global _start
+_start:
+ .byte 0,0,0,0,0,0,0,0
+ .byte 0,0,0,0,0,0,0,0
diff --git a/ld/testsuite/ld-scripts/empty-address-3a.d b/ld/testsuite/ld-scripts/empty-address-3a.d
new file mode 100644
index 0000000..bb12c80
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3a.d
@@ -0,0 +1,8 @@
+#source: empty-address-3.s
+#ld: -T empty-address-3a.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3a.t b/ld/testsuite/ld-scripts/empty-address-3a.t
new file mode 100644
index 0000000..2807e71
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3a.t
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x00000000: { *(.text) }
+ .data ALIGN(0x1000) + (. & (0x1000 - 1)):
+ {
+ *(.data)
+ }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-3b.d b/ld/testsuite/ld-scripts/empty-address-3b.d
new file mode 100644
index 0000000..b3e2a4b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3b.d
@@ -0,0 +1,8 @@
+#source: empty-address-3.s
+#ld: -T empty-address-3b.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3b.t b/ld/testsuite/ld-scripts/empty-address-3b.t
new file mode 100644
index 0000000..4f213af
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3b.t
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x00000000: { *(.text) }
+ .data ALIGN(0x1000) + (. & (0x1000 - 1)):
+ {
+ PROVIDE (__data_start = .);
+ *(.data)
+ }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-3c.d b/ld/testsuite/ld-scripts/empty-address-3c.d
new file mode 100644
index 0000000..41e0afb
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3c.d
@@ -0,0 +1,10 @@
+#source: empty-address-3.s
+#ld: -T empty-address-3c.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+1010 A __data_end
+#...
+0+1010 D __data_start
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3c.t b/ld/testsuite/ld-scripts/empty-address-3c.t
new file mode 100644
index 0000000..6de5198
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3c.t
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x00000000: { *(.text) }
+ .data ALIGN(0x1000) + (. & (0x1000 - 1)):
+ {
+ __data_start = .;
+ *(.data)
+ }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address.exp b/ld/testsuite/ld-scripts/empty-address.exp
new file mode 100644
index 0000000..556aaba
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address.exp
@@ -0,0 +1,25 @@
+# Make sure that "dot" is updated for empty sections if their addresses
+# are set.
+# Copyright 2006
+# Free Software Foundation, Inc.
+#
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+run_dump_test empty-address-1
+run_dump_test empty-address-2a
+run_dump_test empty-address-2b
+run_dump_test empty-address-3a
+run_dump_test empty-address-3b
+run_dump_test empty-address-3c