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]

[6/21] XCOFF R_POS and R_NEG relocations against absolute symbols


The linker currently tries to copy R_POS and R_NEG relocations against
absolute symbols to the .loader section (that is, it tries to make the
relocations dynamic).  This causes the error:

  loader reloc in unrecognized section `*ABS*'

R_POS and R_NEG are simple absolute relocations, so if the symbol is
also absolute, no runtime relocation is needed.  The same is true for
R_RL and R_RLA, which we treat as synonyms for R_POS and R_NEG.

OK to install?

Richard


bfd/
	* xcofflink.c (xcoff_mark, xcoff_link_input_bfd): Don't copy
	R_POS and R_NEG relocations against absolute symbols to the
	.loader section.

ld/testsuite/
	* ld-powerpc/aix-abs-reloc-1.ex, ld-powerpc/aix-abs-reloc-1.im,
	ld-powerpc/aix-abs-reloc-1.od, ld-powerpc/aix-abs-reloc-1.s: New test.
	* ld-powerpc/aix52.exp: Run it.

Index: bfd/xcofflink.c
===================================================================
--- bfd/xcofflink.c	2009-03-10 13:38:53.000000000 +0000
+++ bfd/xcofflink.c	2009-03-10 13:43:53.000000000 +0000
@@ -2335,6 +2335,11 @@ xcoff_mark (struct bfd_link_info *info, 
 		case R_NEG:
 		case R_RL:
 		case R_RLA:
+		  if (h != NULL
+		      && (h->root.type == bfd_link_hash_defined
+			  || h->root.type == bfd_link_hash_defweak)
+		      && bfd_is_abs_section (h->root.u.def.section))
+		    break;
 		  ++xcoff_hash_table (info)->ldrel_count;
 		  if (h != NULL)
 		    h->flags |= XCOFF_LDREL;
@@ -4460,6 +4465,11 @@ #define N_BTSHFT n_btshft
 		case R_NEG:
 		case R_RL:
 		case R_RLA:
+		  if (h != NULL
+		      && (h->root.type == bfd_link_hash_defined
+			  || h->root.type == bfd_link_hash_defweak)
+		      && bfd_is_abs_section (h->root.u.def.section))
+		    break;
 		  /* This reloc needs to be copied into the .loader
 		     section.  */
 		  ldrel.l_vaddr = irel->r_vaddr;
Index: ld/testsuite/ld-powerpc/aix-abs-reloc-1.ex
===================================================================
--- /dev/null	2009-02-06 09:11:03.343159000 +0000
+++ ld/testsuite/ld-powerpc/aix-abs-reloc-1.ex	2009-03-10 13:43:53.000000000 +0000
@@ -0,0 +1,1 @@
+foo
Index: ld/testsuite/ld-powerpc/aix-abs-reloc-1.im
===================================================================
--- /dev/null	2009-02-06 09:11:03.343159000 +0000
+++ ld/testsuite/ld-powerpc/aix-abs-reloc-1.im	2009-03-10 13:43:53.000000000 +0000
@@ -0,0 +1,1 @@
+bar	0xdeadbeef
Index: ld/testsuite/ld-powerpc/aix-abs-reloc-1.od
===================================================================
--- /dev/null	2009-02-06 09:11:03.343159000 +0000
+++ ld/testsuite/ld-powerpc/aix-abs-reloc-1.od	2009-03-10 13:43:53.000000000 +0000
@@ -0,0 +1,7 @@
+
+.*
+
+DYNAMIC RELOCATION RECORDS \(none\)
+
+Contents of section \.data:
+ 10000000 deadbeef .*
Index: ld/testsuite/ld-powerpc/aix-abs-reloc-1.s
===================================================================
--- /dev/null	2009-02-06 09:11:03.343159000 +0000
+++ ld/testsuite/ld-powerpc/aix-abs-reloc-1.s	2009-03-10 13:43:53.000000000 +0000
@@ -0,0 +1,4 @@
+	.globl	foo
+	.csect	foo[RW]
+foo:
+	.long	bar
Index: ld/testsuite/ld-powerpc/aix52.exp
===================================================================
--- ld/testsuite/ld-powerpc/aix52.exp	2009-03-10 13:43:04.000000000 +0000
+++ ld/testsuite/ld-powerpc/aix52.exp	2009-03-10 13:43:53.000000000 +0000
@@ -65,6 +65,12 @@ proc run_aix_test { size name ldopts aso
 }
 
 set aix52tests {
+    {"Relocations against absolute symbols 1"
+     "-shared -bI:aix-abs-reloc-1.im -bE:aix-abs-reloc-1.ex"
+     {} {aix-abs-reloc-1.s}
+     {{objdump -sRj.data aix-abs-reloc-1.od}}
+     "aix-abs-reloc-1.so"}
+
     {"Core sections test 1" "-shared -bE:aix-core-sec-1.ex"
      "" {aix-core-sec-1.s}
      {{objdump -h aix-core-sec-1.hd}}


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