This is the mail archive of the binutils@sourceware.org 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]

Re: [PATCH][m68k] Support generation of multiple GOTs


Andreas Schwab <schwab@suse.de> writes:

> Maxim Kuvyrkov <maxim@codesourcery.com> writes:
>
>> @@ -1689,7 +3101,64 @@ elf_m68k_relocate_section (output_bfd, i
>>  	     in the global offset table.  */
>>  	  if (h != NULL
>>  	      && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
>> -	    break;
>> +	    {
>> +	      BFD_ASSERT (rel->r_addend == 0);
>
> This assertion is bogus.  It it perfectly valid for references to
> _GLOBAL_OFFSET_TABLE_ to have an addend, it's the normal PIC setup on
> m68k:
>
>            lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a5

Tested on m68k-linux and checked in as obvious.

Andreas.

2008-06-29  Andreas Schwab  <schwab@suse.de>

	* elf32-m68k.c (elf_m68k_relocate_section): Don't ignore existing
	addend on _GLOBAL_OFFSET_TABLE_.

ld/testsuite/:
	* ld-m68k/got-1.s: New file.
	* ld-m68k/got-1.d: New dump test.
	* ld-m68k/m68k.exp: Run it.

Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.107
diff -u -a -p -r1.107 elf32-m68k.c
--- bfd/elf32-m68k.c	21 May 2008 12:01:36 -0000	1.107
+++ bfd/elf32-m68k.c	29 Jun 2008 10:50:26 -0000
@@ -3135,8 +3135,6 @@ elf_m68k_relocate_section (output_bfd, i
 	  if (h != NULL
 	      && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
 	    {
-	      BFD_ASSERT (rel->r_addend == 0);
-
 	      if (elf_m68k_hash_table (info)->local_gp_p)
 		{
 		  bfd_vma sgot_output_offset;
@@ -3185,7 +3183,7 @@ elf_m68k_relocate_section (output_bfd, i
 
 		  /* Adjust GOT pointer to point to the GOT
 		     assigned to input_bfd.  */
-		  rel->r_addend = sgot_output_offset + got_offset;
+		  rel->r_addend += sgot_output_offset + got_offset;
 		}
 	      else
 		BFD_ASSERT (got == NULL || got->offset == 0);
--- ld/testsuite/ld-m68k/m68k.exp.~1.7.~	2008-06-29 09:48:38.000000000 +0200
+++ ld/testsuite/ld-m68k/m68k.exp	2008-06-29 12:06:32.000000000 +0200
@@ -73,6 +73,7 @@ foreach { id sources } { a { plt1.s } b
 # 4 - 16384
 # 5 - 16385
 
+run_dump_test "got-1"
 run_dump_test "got-single-12-ok"
 run_dump_test "got-single-13-er"
 run_dump_test "got-negative-14-ok"
Index: ld/testsuite/ld-m68k/got-1.s
===================================================================
RCS file: ld/testsuite/ld-m68k/got-1.s
diff -N ld/testsuite/ld-m68k/got-1.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-m68k/got-1.s	29 Jun 2008 10:50:25 -0000
@@ -0,0 +1,18 @@
+#NO_APP
+	.file	"got-1.c"
+	.text
+	.align	2
+	.globl	foo
+	.type	foo, @function
+foo:
+	link.w %fp,#0
+	move.l %a5,-(%sp)
+	lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %a5
+	move.l a@GOT(%a5),%d0
+	move.l %d0,%a0
+	move.l (%a0),%d0
+	move.l (%sp)+,%a5
+	unlk %fp
+	rts
+	.size	foo, .-foo
+	.section	.note.GNU-stack,"",@progbits
Index: ld/testsuite/ld-m68k/got-1.d
===================================================================
RCS file: ld/testsuite/ld-m68k/got-1.d
diff -N ld/testsuite/ld-m68k/got-1.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-m68k/got-1.d	29 Jun 2008 10:50:25 -0000
@@ -0,0 +1,19 @@
+#source: got-1.s
+#ld: -shared
+#readelf: -d -r
+
+Dynamic section at offset .* contains 9 entries:
+  Tag        Type                         Name/Value
+ 0x00000004 \(HASH\)                       0x[0-9a-f]+
+ 0x00000005 \(STRTAB\)                     0x[0-9a-f]+
+ 0x00000006 \(SYMTAB\)                     0x[0-9a-f]+
+ 0x0000000a \(STRSZ\)                      [0-9]+ \(bytes\)
+ 0x0000000b \(SYMENT\)                     16 \(bytes\)
+ 0x00000007 \(RELA\)                       0x[0-9a-f]+
+ 0x00000008 \(RELASZ\)                     12 \(bytes\)
+ 0x00000009 \(RELAENT\)                    12 \(bytes\)
+ 0x00000000 \(NULL\)                       0x0
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ Offset     Info    Type            Sym.Value  Sym. Name \+ Addend
+[0-9a-f]+  [0-9a-f]+ R_68K_GLOB_DAT    00000000   a \+ 0

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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