[PATCH] Do not allow .global on section symbols
Nick Clifton
nickc@cambridge.redhat.com
Tue Jun 5 01:29:00 GMT 2001
Hi Guys,
A customer recently discovered that GAS did not stop you using
.globl on a section symbol. Unfortunately it did corrupt the symbol
table that was produced (moving sections symbols into the local
symbol area), which then resulted in seg faults inside the linker.
To see this, assemble and link the following x86 test program:
.section ddd,"a"
.align 1
.global ddd
ddd_data:
.space 0x0064
.section ccc, "ax"
.align 2
ccc_code:
mov %eax,ddd_data
The patch below fixes this by preventing .globl from changing a
section symbol's status and instead making it issue a warning
message.
I was not sure however, how to add this code as a test case. I did
not want to add it to the assembler's testsuite, since it needs the
linker in order to demonstrate the fault, and I did not want to add
it to the linker's testsuite since it contains ELF and x86 specific
code. Any suggestions for how to incorporate it as a test as most
welcome.
Cheers
Nick
2001-06-05 Nick Clifton <nickc@cambridge.redhat.com>
* symbols.c (S_SET_EXTERNAL): Do not override a section symbol's
status.
Index: gas/symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.24
diff -p -r1.24 symbols.c
*** symbols.c 2001/05/25 10:07:43 1.24
--- symbols.c 2001/06/05 08:22:06
*************** S_SET_EXTERNAL (s)
*** 1824,1829 ****
--- 1824,1840 ----
/* Let .weak override .global. */
return;
}
+ if (s->bsym->flags & BSF_SECTION_SYM)
+ {
+ char * file;
+ unsigned int line;
+
+ /* Do not reassign section symbols. */
+ as_where (& file, & line);
+ as_warn_where (file, line,
+ _("Section symbols are already global"));
+ return;
+ }
s->bsym->flags |= BSF_GLOBAL;
s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK);
}
More information about the Binutils
mailing list