Apply H.J.'s patch to fix label arithmetic when multiple same-name sections are involved

This commit is contained in:
Nick Clifton 2004-05-11 15:53:47 +00:00
parent d0b57c3ab1
commit 22fe14ad41
10 changed files with 110 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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
{

View File

@ -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 */

View File

@ -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...

View File

@ -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\\\]\""
}

View File

@ -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

View File

@ -1,2 +1,2 @@
.section .text,"axG",@progbits,.foo_group,comdat
.section .text,"axG",%progbits,.foo_group,comdat
.byte 1

View File

@ -0,0 +1,12 @@
#readelf: --sections
#name: label arithmetic with multiple same-name sections
#...
[ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*
#...
[ ]*\[.*\][ ]+\.data[ ]+PROGBITS.*
#...
[ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*
#...
[ ]*\[.*\][ ]+foo[ ]+GROUP.*
#pass

View File

@ -0,0 +1,11 @@
.text
.L1:
.align 4
.L2:
.L3:
.section .data,"",%progbits
.long .L3 - .L1
.section .text,"axG",%progbits,foo,comdat
.word 0