gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / embedspu.sh
index 49776b00d7698249f943d2aaf8e9fb1278f2d5bf..6a0fbea3d1df644d43068b58d9a36b95e09f78f9 100644 (file)
@@ -1,13 +1,13 @@
-#! /bin/sh 
+#! /bin/sh
 # Embed an SPU ELF executable into a PowerPC object file.
 #
-# Copyright 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2006-2020 Free Software Foundation, Inc.
 #
 # This file is part of GNU Binutils.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
@@ -119,12 +119,13 @@ main ()
   toe=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *\.toe *[PROGN]*BITS *\([0-9a-f]*\).*,\1 \2,p'`
   toe_addr=`echo $toe | sed -n -e 's,.* ,,p'`
   toe=`echo $toe | sed -n -e 's, .*,,p'`
+  has_ea=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *\._ea *PROGBITS.*,\1,p'`
   # For loaded sections, pick off section number, address, and file offset
   sections=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *[^ ]* *PROGBITS *\([0-9a-f]*\) *\([0-9a-f]*\).*,\1 \2 \3,p'`
   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.
@@ -138,20 +139,20 @@ main ()
   #    sections.
   #    Find all _EAR_ symbols in .toe using readelf, sort by address, and
   #    write the address of the corresponding PowerPC symbol in a table
-  #    built in .data.spetoe.  For _EAE_ symbols not in .toe, create
+  #    built in .data.spetoe.  For _EAR_ symbols not in .toe, create
   #    .reloc commands to relocate their location directly.
   # 3. Look for R_SPU_PPU32 and R_SPU_PPU64 relocations in the SPU ELF image
   #    and create .reloc commands for them.
   # 4. Write a struct spe_program_handle to .data.
   # 5. Write a table of _SPUEAR_ symbols.
   ${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \
-       -Wa,-mbig -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
+       -Wa,-mbig -Wa,-noexecstack -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
  .section .data.spetoe,"aw",@progbits
  .p2align 7
 __spetoe__:
 `${READELF} -s -W ${INFILE} | grep ' _EAR_' | sort -k 2 | awk \
 'BEGIN { \
-       addr = strtonum ("0x" "'${toe_addr-0}'"); \
+       addr = strtonum ("0x" "'${toe_addr:-0}'"); \
        split ("'"${sections}"'", s, " "); \
        for (i = 1; i in s; i += 3) { \
            sec_off[s[i]] = strtonum ("0x" s[i+2]) - strtonum ("0x" s[i+1]); \
@@ -198,22 +199,24 @@ $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__))
+#if ${has_ea:-0}
+ .section .data.speelf,"aw",@progbits
+#elif defined (HAS_RELOCS) && (defined (__PIC__) || defined (__PIE__))
  .section .data.rel.ro.speelf,"a",@progbits
 #else
  .section .rodata.speelf,"a",@progbits
@@ -222,7 +225,7 @@ $3 ~ /unrecognized:/ { \
 __speelf__:
  .incbin "${INFILE}"
 
- .section .data,"aw",@progbits
+ .section .data.spehandle,"aw",@progbits
  .globl ${SYMBOL}
  .type ${SYMBOL}, @object
 # fill in a struct spe_program_handle
@@ -248,7 +251,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.026299 seconds and 4 git commands to generate.