public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Do not allow .global on section symbols
@ 2001-06-05  1:29 Nick Clifton
  2001-06-05 11:29 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2001-06-05  1:29 UTC (permalink / raw)
  To: binutils

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);
  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-05 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-05  1:29 [PATCH] Do not allow .global on section symbols Nick Clifton
2001-06-05 11:29 ` Ian Lance Taylor
2001-06-05 13:29   ` H . J . Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).