diff options
author | Nick Clifton <nickc@redhat.com> | 2004-05-11 15:53:47 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2004-05-11 15:53:47 +0000 |
commit | 22fe14ad41ac9f7b8fd61bc25e08e51094dcb116 (patch) | |
tree | 30b9b33fb64957ef4f0ebbf61820a56e1a86a8ca | |
parent | d0b57c3ab13c612490eedcf66de5e3826d0fc16c (diff) | |
download | gdb-22fe14ad41ac9f7b8fd61bc25e08e51094dcb116.zip gdb-22fe14ad41ac9f7b8fd61bc25e08e51094dcb116.tar.gz gdb-22fe14ad41ac9f7b8fd61bc25e08e51094dcb116.tar.bz2 |
Apply H.J.'s patch to fix label arithmetic when multiple same-name sections are involved
-rw-r--r-- | gas/ChangeLog | 12 | ||||
-rw-r--r-- | gas/doc/as.texinfo | 52 | ||||
-rw-r--r-- | gas/subsegs.c | 6 | ||||
-rw-r--r-- | gas/symbols.c | 13 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/elf.exp | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/group0.s | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/group1.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section4.d | 12 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section4.s | 11 |
10 files changed, 110 insertions, 15 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 5ecda6f..ff7f827 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,15 @@ +2004-05-11 Nick Clifton <nickc@redhat.com> + + * doc/as.texinfo (Section): Document G and T flags to .section + directive. Document the extra arguments that the G flag + requires. Document the #tls flag. + +2004-05-11 H.J. Lu <hongjiu.lu@intel.com> + + * subsegs.c (section_symbol): Create a new section symbol if + the existing one doesn't match. + * symbols.c (symbol_set_bfdsym): Don't reset BFD section symbol. + 2004-05-07 Richard Sandiford <rsandifo@redhat.com> * config/tc-mips.c (append_insn, mips_emit_delays): Extend -mfix-vr4120 diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index cee3fbf..056fa6d 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -5211,7 +5211,7 @@ This is one of the ELF section stack manipulation directives. The others are For ELF targets, the @code{.section} directive is used like this: @smallexample -.section @var{name} [, "@var{flags}"[, @@@var{type}[, @@@var{entsize}]]] +.section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]] @end smallexample The optional @var{flags} argument is a quoted string which may contain any @@ -5227,6 +5227,10 @@ section is executable section is mergeable @item S section contains zero terminated strings +@item G +section is a member of a section group +@item T +section is used for thread-local-storage @end table The optional @var{type} argument may contain one of the following constants: @@ -5235,18 +5239,50 @@ The optional @var{type} argument may contain one of the following constants: section contains data @item @@nobits section does not contain data (i.e., section only occupies space) +@item @@note +section contains data which is used by things other than the program @end table Note on targets where the @code{@@} character is the start of a comment (eg ARM) then another character is used instead. For example the ARM port uses the @code{%} character. -If @var{flags} contains @code{M} flag, @var{type} argument must be specified -as well as @var{entsize} argument. Sections with @code{M} flag but not -@code{S} flag must contain fixed size constants, each @var{entsize} octets -long. Sections with both @code{M} and @code{S} must contain zero terminated -strings where each character is @var{entsize} bytes long. The linker may remove -duplicates within sections with the same name, same entity size and same flags. +If @var{flags} contains the @code{M} symbol then the @var{type} argument must +be specified as well as an extra argument - @var{entsize} - like this: + +@smallexample +.section @var{name} , "@var{flags}"M, @@@var{type}, @var{entsize} +@end smallexample + +Sections with the @code{M} flag but not @code{S} flag must contain fixed size +constants, each @var{entsize} octets long. Sections with both @code{M} and +@code{S} must contain zero terminated strings where each character is +@var{entsize} bytes long. The linker may remove duplicates within sections with +the same name, same entity size and same flags. @var{entsize} must be an +absolute expression. + +If @var{flags} contains the @code{G} symbol then the @var{type} argument must +be present along with an additional field like this: + +@smallexample +.section @var{name} , "@var{flags}"G, @@@var{type}, @var{GroupName}[, @var{linkage}] +@end smallexample + +The @var{GroupName} field specifies the name of the section group to which this +particular section belongs. The optional linkage field can contain: +@table @code +@item comdat +indicates that only one copy of this section should be retained +@item .gnu.linkonce +an alias for comdat +@end table + +Note - if both the @var{M} and @var{G} flags are present then the fields for +the Merge flag should come first, like this: + +@smallexample +.section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}] +@end smallexample If no flags are specified, the default flags depend upon the section name. If the section name is not recognized, the default will be for the section to have @@ -5269,6 +5305,8 @@ section is allocatable section is writable @item #execinstr section is executable +@item #tls +section is used for thread local storage @end table This directive replaces the current section and subsection. The replaced diff --git a/gas/subsegs.c b/gas/subsegs.c index b2432e9..9e46cfe 100644 --- a/gas/subsegs.c +++ b/gas/subsegs.c @@ -1,6 +1,6 @@ /* subsegs.c - subsegments - Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2002 + 1999, 2000, 2002, 2004 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -524,7 +524,9 @@ section_symbol (segT sec) else { s = symbol_find_base (sec->symbol->name, 0); - if (s == NULL) + /* We have to make sure it is the right symbol when we + have multiple sections with the same section name. */ + if (s == NULL || S_GET_SEGMENT (s) != sec) s = symbol_new (sec->symbol->name, sec, 0, &zero_address_frag); else { diff --git a/gas/symbols.c b/gas/symbols.c index 761a020..136227d 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1,6 +1,6 @@ /* symbols.c -symbol table- Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003 + 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -2260,7 +2260,16 @@ symbol_set_bfdsym (symbolS *s, asymbol *bsym) { if (LOCAL_SYMBOL_CHECK (s)) s = local_symbol_convert ((struct local_symbol *) s); - s->bsym = bsym; + /* Usually, it is harmless to reset a symbol to a BFD section + symbol. For example, obj_elf_change_section sets the BFD symbol + of an old symbol with the newly created section symbol. But when + we have multiple sections with the same name, the newly created + section may have the same name as an old section. We check if the + old symbol has been already marked as a section symbol before + resetting it. */ + if ((s->bsym->flags & BSF_SECTION_SYM) == 0) + s->bsym = bsym; + /* else XXX - What do we do now ? */ } #endif /* BFD_ASSEMBLER */ diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 4e7af29..b645312 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2004-05-11 Nick Clifton <nickc@redhat.com> + + * gas/elf/section4.s: New test. Checks label arithmetic when + multiple same-name sections exist. + * gas/elf/section4.d: New file: Expected section list + * gas/elf/elf.exp: Run the new test. + * gas/elf/group0.s: Use % instead of @ for type argument to + .section directive (for compatability with ARM port). + * gas/elf/group1.s: Likewise. + 2004-05-07 Richard Sandiford <rsandifo@redhat.com> * gas/mips/vr4122.[sd]: Rename to... diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 4680dce..036c669 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -55,7 +55,8 @@ if { ([istarget "*-*-elf*"] run_dump_test "section0" run_dump_test "section1" run_list_test "section2" "$target_machine" "-al" "" - run_dump_test "section3" + run_dump_test "section3" + run_dump_test "section4" run_dump_test "symver" run_list_test "type" "" "" "| grep \"1 \\\[FONT\\\]\"" } diff --git a/gas/testsuite/gas/elf/group0.s b/gas/testsuite/gas/elf/group0.s index 26bdda2..4707c69 100644 --- a/gas/testsuite/gas/elf/group0.s +++ b/gas/testsuite/gas/elf/group0.s @@ -1,4 +1,4 @@ - .section .foo,"axG",@progbits,.foo_group,comdat + .section .foo,"axG",%progbits,.foo_group,comdat .byte 1 - .section .bar,"aG",@progbits,.foo_group,comdat + .section .bar,"aG",%progbits,.foo_group,comdat .byte 1 diff --git a/gas/testsuite/gas/elf/group1.s b/gas/testsuite/gas/elf/group1.s index 1645f0b..f02f150 100644 --- a/gas/testsuite/gas/elf/group1.s +++ b/gas/testsuite/gas/elf/group1.s @@ -1,2 +1,2 @@ - .section .text,"axG",@progbits,.foo_group,comdat + .section .text,"axG",%progbits,.foo_group,comdat .byte 1 diff --git a/gas/testsuite/gas/elf/section4.d b/gas/testsuite/gas/elf/section4.d new file mode 100644 index 0000000..2e417e7 --- /dev/null +++ b/gas/testsuite/gas/elf/section4.d @@ -0,0 +1,12 @@ +#readelf: --sections +#name: label arithmetic with multiple same-name sections + +#... +[ ]*\[.*\][ ]+\.text[ ]+PROGBITS.* +#... +[ ]*\[.*\][ ]+\.data[ ]+PROGBITS.* +#... +[ ]*\[.*\][ ]+\.text[ ]+PROGBITS.* +#... +[ ]*\[.*\][ ]+foo[ ]+GROUP.* +#pass diff --git a/gas/testsuite/gas/elf/section4.s b/gas/testsuite/gas/elf/section4.s new file mode 100644 index 0000000..682ccb6 --- /dev/null +++ b/gas/testsuite/gas/elf/section4.s @@ -0,0 +1,11 @@ + .text +.L1: + .align 4 +.L2: +.L3: + .section .data,"",%progbits + .long .L3 - .L1 + .section .text,"axG",%progbits,foo,comdat + .word 0 + +
\ No newline at end of file |