Mention PR ld/4701.
[deliverable/binutils-gdb.git] / binutils / embedspu.sh
index 7a321589d1b8455f773b24be0494239045e5580e..6611172814e62a9d58692c7d705a3579eeab006c 100644 (file)
@@ -124,7 +124,7 @@ main ()
   sections=`echo ${sections}`
   # For relocation sections, pick off file offset and info (points to
   # section where relocs apply)
-  relas=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *[0-9]*\] *[^ ]* *RELA *[0-9a-f]* *0*\([0-9a-f][0-9a-f]*\) .*\([0-9a-f][0-9a-f]*\) *[0-9a-f][0-9a-f]*$,\1 \2,p'`
+  relas=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *[0-9]*\] *[^ ]* *RELA *[0-9a-f]* *0*\([0-9a-f][0-9a-f]*\).* \([0-9a-f][0-9a-f]*\) *[0-9a-f][0-9a-f]*$,\1 \2,p'`
   relas=`echo ${relas}`
 
   # Build embedded SPU image.
@@ -146,11 +146,6 @@ main ()
   # 5. Write a table of _SPUEAR_ symbols.
   ${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \
        -Wa,-mbig -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
- .section .rodata.speelf,"a",@progbits
- .p2align 7
-__speelf__:
- .incbin "${INFILE}"
-
  .section .data.spetoe,"aw",@progbits
  .p2align 7
 __spetoe__:
@@ -181,6 +176,7 @@ $7 != "'${toe}'" && $7 in sec_off { \
        print "#else"; \
        print " .reloc __speelf__+" strtonum ("0x" $2) + sec_off[$7] + 4 ", R_PPC_ADDR32, " ($8 == "_EAR_" ? "__speelf__" : substr($8, 6)); \
        print "#endif"; \
+       if (!donedef) { print "#define HAS_RELOCS 1"; donedef = 1; }; \
 } \
 $7 != "'${toe}'" && ! $7 in sec_off { \
        print "#error Section not found for " $8; \
@@ -202,19 +198,29 @@ $7 != "'${toe}'" && ! $7 in sec_off { \
 } \
 $3 ~ /R_SPU_PPU/ { \
        print "#ifdef _LP64"; \
-       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" substr($3, 10) ", " $5 "+0x" $7; \
+       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" substr($3, 10) ", " ($5 != "" ? $5 "+0x" $7 : "__speelf__ + 0x" $4); \
        print "#else"; \
-       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + (substr($3, 10) == "64" ? 4 : 0)", R_PPC_ADDR32, " $5 "+0x" $7; \
+       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + (substr($3, 10) == "64" ? 4 : 0)", R_PPC_ADDR32, " ($5 != "" ? $5 "+0x" $7 : "__speelf__ + 0x" $4); \
        print "#endif"; \
+       if (!donedef) { print "#define HAS_RELOCS 1"; donedef = 1; }; \
 } \
 $3 ~ /unrecognized:/ { \
        print "#ifdef _LP64"; \
-       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" ($4 == "f" ? "64" : "32") ", " $6 "+0x" $8; \
+       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" ($4 == "f" ? "64" : "32") ", " ($6 != "" ? $6 "+0x" $8 : "__speelf__ + 0x" $5); \
        print "#else"; \
-       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + ($4 == "f" ? 4 : 0)", R_PPC_ADDR32, " $6 "+0x" $8; \
+       print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + ($4 == "f" ? 4 : 0)", R_PPC_ADDR32, " ($6 != "" ? $6 "+0x" $8 : "__speelf__ + 0x" $5); \
        print "#endif"; \
+       if (!donedef) { print "#define HAS_RELOCS 1"; donedef = 1; }; \
 } \
 '`
+#if defined (HAS_RELOCS) && (defined (__PIC__) || defined (__PIE__))
+ .section .data.rel.ro.speelf,"a",@progbits
+#else
+ .section .rodata.speelf,"a",@progbits
+#endif
+ .p2align 7
+__speelf__:
+ .incbin "${INFILE}"
 
  .section .data,"aw",@progbits
  .globl ${SYMBOL}
@@ -242,7 +248,7 @@ ${SYMBOL}:
        print " .type '${SYMBOL}'_" substr($8, 9) ", @object"; \
        print " .size '${SYMBOL}'_" substr($8, 9) ", 4"; \
        print "'${SYMBOL}'_" substr($8, 9) ":"; \
-       print " .int " $2; \
+       print " .int 0x" $2; \
 } \
 '`
 EOF
This page took 0.025238 seconds and 4 git commands to generate.