This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed, MMIX: gas bugs with global registers for weak and commonsymbols


GCC is good at finding bugs that slip through what you thought
was extensive testing. :-/

gas:
	* config/tc-mmix.c (tc_gen_reloc): Don't try and take the value of
	common and weak symbols.  Handle common and weak symbols as
	undefined symbols with regards to GREG handling and merging.
	(mmix_frob_file): Ditto.

gas/testsuite:
	* gas/mmix/basep-8.d, gas/mmix/basep-9.s, gas/mmix/basep-9.d,
	gas/mmix/err-bpo6.s, gas/mmix/basep-8.s, gas/mmix/basep-10.d,
	gas/mmix/basep-10.s, gas/mmix/basep-11.s, gas/mmix/basep-11.d: New
	tests for base-plus-offset relocations and global register
	allocations for weak and common symbols.

Index: tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.4
diff -p -c -r1.4 tc-mmix.c
*** tc-mmix.c	2002/02/01 08:09:45	1.4
--- tc-mmix.c	2002/02/04 03:28:38
*************** tc_gen_reloc (section, fixP)
*** 2587,2600 ****
       fixS *fixP;
  {
    bfd_signed_vma val
!     = fixP->fx_offset + (fixP->fx_addsy ? S_GET_VALUE (fixP->fx_addsy) : 0);
    arelent *relP;
    bfd_reloc_code_real_type code = BFD_RELOC_NONE;
    char *buf  = fixP->fx_where + fixP->fx_frag->fr_literal;
    symbolS *addsy = fixP->fx_addsy;
    asection *addsec = addsy == NULL ? NULL : S_GET_SEGMENT (addsy);
    asymbol *baddsy = addsy != NULL ? symbol_get_bfdsym (addsy) : NULL;
!   bfd_vma addend = val - (baddsy == NULL ? 0 : bfd_asymbol_value (baddsy));

    /* A single " LOCAL expression" in the wrong section will not work when
       linking to MMO; relocations for zero-content sections are then
--- 2587,2606 ----
       fixS *fixP;
  {
    bfd_signed_vma val
!     = fixP->fx_offset
!     + (fixP->fx_addsy != NULL
!        && !S_IS_WEAK (fixP->fx_addsy)
!        && !S_IS_COMMON (fixP->fx_addsy)
!        ? S_GET_VALUE (fixP->fx_addsy) : 0);
    arelent *relP;
    bfd_reloc_code_real_type code = BFD_RELOC_NONE;
    char *buf  = fixP->fx_where + fixP->fx_frag->fr_literal;
    symbolS *addsy = fixP->fx_addsy;
    asection *addsec = addsy == NULL ? NULL : S_GET_SEGMENT (addsy);
    asymbol *baddsy = addsy != NULL ? symbol_get_bfdsym (addsy) : NULL;
!   bfd_vma addend
!     = val - (baddsy == NULL || S_IS_COMMON (addsy) || S_IS_WEAK (addsy)
! 	     ? 0 : bfd_asymbol_value (baddsy));

    /* A single " LOCAL expression" in the wrong section will not work when
       linking to MMO; relocations for zero-content sections are then
*************** tc_gen_reloc (section, fixP)
*** 2720,2726 ****
  	  struct mmix_symbol_gregs *gregs;
  	  struct mmix_symbol_greg_fixes *fix;

! 	  if (S_IS_DEFINED (addsy))
  	    {
  	      if (! symbol_section_p (addsy) && ! bfd_is_abs_section (addsec))
  		as_fatal (_("internal: BFD_RELOC_MMIX_BASE_PLUS_OFFSET not resolved to section"));
--- 2726,2734 ----
  	  struct mmix_symbol_gregs *gregs;
  	  struct mmix_symbol_greg_fixes *fix;

! 	  if (S_IS_DEFINED (addsy)
! 	      && !bfd_is_com_section (addsec)
! 	      && !S_IS_WEAK (addsy))
  	    {
  	      if (! symbol_section_p (addsy) && ! bfd_is_abs_section (addsec))
  		as_fatal (_("internal: BFD_RELOC_MMIX_BASE_PLUS_OFFSET not resolved to section"));
*************** mmix_frob_file ()
*** 3592,3598 ****

        /* If the symbol is defined, then it must be resolved to a section
  	 symbol at this time, or else we don't know how to handle it.  */
!       if (S_IS_DEFINED (sym))
  	{
  	  if (! symbol_section_p (sym)
  	      && ! bfd_is_abs_section (S_GET_SEGMENT (sym)))
--- 3600,3608 ----

        /* If the symbol is defined, then it must be resolved to a section
  	 symbol at this time, or else we don't know how to handle it.  */
!       if (S_IS_DEFINED (sym)
! 	  && !bfd_is_com_section (S_GET_SEGMENT (sym))
! 	  && !S_IS_WEAK (sym))
  	{
  	  if (! symbol_section_p (sym)
  	      && ! bfd_is_abs_section (S_GET_SEGMENT (sym)))

*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-8.d	Sun Feb  3 05:41:48 2002
***************
*** 0 ****
--- 1,30 ----
+ #as: -linker-allocated-gregs
+ #objdump: -drt
+
+ # Since we don't merge BPO-relocs until linking with
+ # -linker-allocated-gregs, we automatically correctly handle the two
+ # seemingly neighboring comm-symbols that don't merge well at
+ # assembly-time.
+
+ .*:     file format elf64-mmix
+
+ SYMBOL TABLE:
+ 0+ l    d  \.text	0+
+ 0+ l    d  \.data	0+
+ 0+ l    d  \.bss	0+
+ 0+ l       \.bss	0+4 comm_symbol3
+ 0+4 l       \.bss	0+4 comm_symbol4
+ 0+4       O \*COM\*	0+4 comm_symbol1
+ 0+4       O \*COM\*	0+4 comm_symbol2
+
+ Disassembly of section \.text:
+
+ 0+ <\.text>:
+    0:	232a0000 	addu \$42,\$0,0
+ 			2: R_MMIX_BASE_PLUS_OFFSET	comm_symbol1
+    4:	232b0000 	addu \$43,\$0,0
+ 			6: R_MMIX_BASE_PLUS_OFFSET	comm_symbol2
+    8:	232c0000 	addu \$44,\$0,0
+ 			a: R_MMIX_BASE_PLUS_OFFSET	\.bss
+    c:	232d0000 	addu \$45,\$0,0
+ 			e: R_MMIX_BASE_PLUS_OFFSET	\.bss\+0x4
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-9.s	Sun Feb  3 05:12:33 2002
***************
*** 0 ****
--- 1,9 ----
+ # Test that we handle COMM-type symbols with base-plus-offset relocs.
+  .comm comm_symbol1,4,4
+  .lcomm comm_symbol3,4
+  GREG comm_symbol1
+  GREG comm_symbol3
+  LDA $42,comm_symbol1
+  LDA $44,comm_symbol3
+  LDA $45,comm_symbol4
+  .lcomm comm_symbol4,4
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-9.d	Sun Feb  3 21:11:33 2002
***************
*** 0 ****
--- 1,29 ----
+ #objdump: -srt
+
+ .*:     file format elf64-mmix
+
+ SYMBOL TABLE:
+ 0+ l    d  \.text	0+
+ 0+ l    d  \.data	0+
+ 0+ l    d  \.bss	0+
+ 0+ l       \.bss	0+4 comm_symbol3
+ 0+4 l       \.bss	0+4 comm_symbol4
+ 0+ l    d  \.MMIX\.reg_contents	0+
+ 0+4       O \*COM\*	0+4 comm_symbol1
+
+ RELOCATION RECORDS FOR \[\.text\]:
+ OFFSET           TYPE              VALUE
+ 0+2 R_MMIX_REG        \.MMIX\.reg_contents\+0x0+8
+ 0+6 R_MMIX_REG        \.MMIX\.reg_contents
+ 0+a R_MMIX_REG        \.MMIX\.reg_contents
+
+ RELOCATION RECORDS FOR \[\.MMIX\.reg_contents\]:
+ OFFSET           TYPE              VALUE
+ 0+ R_MMIX_64         \.bss
+ 0+8 R_MMIX_64         comm_symbol1
+
+ Contents of section \.text:
+  0000 232a0000 232c0000 232d0004           .*
+ Contents of section \.data:
+ Contents of section \.MMIX\.reg_contents:
+  0000 00000000 00000000 00000000 00000000  .*
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/err-bpo6.s	Sun Feb  3 20:01:19 2002
***************
*** 0 ****
--- 1,21 ----
+ % { dg-do assemble { target mmix-*-* } }
+
+ # Test that we handle COMM-type symbols with base-plus-offset relocs, but
+ # that we don't merge ones that may be separately merged with other
+ # symbols at link-time.  Likewise for weak symbols.
+  .comm comm_symbol1,4,4
+  .lcomm comm_symbol3,4
+  GREG comm_symbol1
+  GREG comm_symbol3
+  GREG xx
+  .weak xx
+ xx:
+  LDA $47,yy		% { dg-error "no suitable GREG definition" "" }
+  LDA $46,xx
+  LDA $42,comm_symbol1
+  LDA $43,comm_symbol2	% { dg-error "no suitable GREG definition" "" }
+  LDA $44,comm_symbol3
+  LDA $45,comm_symbol4
+ yy:
+  .comm comm_symbol2,4,4
+  .lcomm comm_symbol4,4
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-8.s	Sun Feb  3 05:40:02 2002
***************
*** 0 ****
--- 1,9 ----
+ # Test that we handle COMM-type symbols with base-plus-offset relocs.
+  .comm comm_symbol1,4,4
+  .lcomm comm_symbol3,4
+  LDA $42,comm_symbol1
+  LDA $43,comm_symbol2
+  LDA $44,comm_symbol3
+  LDA $45,comm_symbol4
+  .comm comm_symbol2,4,4
+  .lcomm comm_symbol4,4
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-10.d	Sun Feb  3 19:58:32 2002
***************
*** 0 ****
--- 1,34 ----
+ #as: -linker-allocated-gregs
+ #objdump: -srt
+
+ .*:     file format elf64-mmix
+
+ SYMBOL TABLE:
+ 0+ l    d  \.text	0+
+ 0+ l    d  \.data	0+
+ 0+ l    d  \.bss	0+
+ 0+4 l       \.text	0+ w4
+ 0+10 l       \.text	0+ w2
+ 0+ l    d  \.MMIX\.reg_contents	0+
+ 0+c  w      \.text	0+ w1
+ 0+8  w      \.text	0+ w3
+
+
+ RELOCATION RECORDS FOR \[\.text\]:
+ OFFSET           TYPE              VALUE
+ 0+6 R_MMIX_BASE_PLUS_OFFSET  w1
+ 0+a R_MMIX_REG        \.MMIX\.reg_contents
+ 0+e R_MMIX_REG        \.MMIX\.reg_contents\+0x0+8
+ 0+12 R_MMIX_REG        \.MMIX\.reg_contents\+0x0+8
+
+ RELOCATION RECORDS FOR \[\.MMIX\.reg_contents\]:
+ OFFSET           TYPE              VALUE
+ 0+ R_MMIX_64         w3
+ 0+8 R_MMIX_64         \.text\+0x0+4
+
+ Contents of section \.text:
+  0000 fd000000 232a0000 232b0000 232c000c  .*
+  0010 232d0000                             .*
+ Contents of section \.data:
+ Contents of section \.MMIX\.reg_contents:
+  0000 00000000 00000000 00000000 00000000  .*
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-10.s	Sun Feb  3 19:59:43 2002
***************
*** 0 ****
--- 1,16 ----
+ # Test that we handle weak symbols with base-plus-offset relocs mixed with
+ # GREG defs.
+  .weak w1
+  .weak w3
+  GREG w4
+  GREG w3
+  SWYM
+ w4:
+  LDA $42,w1
+ w3:
+  LDA $43,w3
+ w1:
+  LDA $44,w2
+ w2:
+  LDA $45,w4
+
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-11.s	Sun Feb  3 19:59:36 2002
***************
*** 0 ****
--- 1,13 ----
+ # Test that we handle weak symbols with base-plus-offset relocs.
+  .weak w1
+  .weak w3
+  SWYM
+ w4:
+  LDA $42,w1
+ w3:
+  LDA $43,w3
+ w1:
+  LDA $44,w2
+ w2:
+  LDA $45,w4
+
*** /dev/null	Tue Jan  1 05:00:00 1980
--- gas/mmix/basep-11.d	Sun Feb  3 20:45:49 2002
***************
*** 0 ****
--- 1,25 ----
+ #as: -linker-allocated-gregs
+ #objdump: -srt
+
+ .*:     file format elf64-mmix
+
+ SYMBOL TABLE:
+ 0+ l    d  \.text	0+
+ 0+ l    d  \.data	0+
+ 0+ l    d  \.bss	0+
+ 0+4 l       \.text	0+ w4
+ 0+10 l       \.text	0+ w2
+ 0+c  w      \.text	0+ w1
+ 0+8  w      \.text	0+ w3
+
+ RELOCATION RECORDS FOR \[\.text\]:
+ OFFSET           TYPE              VALUE
+ 0+6 R_MMIX_BASE_PLUS_OFFSET  w1
+ 0+a R_MMIX_BASE_PLUS_OFFSET  w3
+ 0+e R_MMIX_BASE_PLUS_OFFSET  \.text\+0x0+10
+ 0+12 R_MMIX_BASE_PLUS_OFFSET  \.text\+0x0+4
+
+ Contents of section \.text:
+  0000 fd000000 232a0000 232b0000 232c0000  .*
+  0010 232d0000                             .*
+ Contents of section \.data:

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]