Fix the order of SHLIB_RODATA_ADDR in elf.sc
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Jan 2018 13:05:25 +0000 (05:05 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Jan 2018 13:05:25 +0000 (05:05 -0800)
elf.sc has

  if test -n "${RODATA_ADDR}"; then
    RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Set RODATA_ADDR
    RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
    ^^^^^^^^^^ Set RODATA_ADDR with ${RODATA_ADDR}
  fi
  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
    ^^^^^^^^^^ Set SHLIB_RODATA_ADDR
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Override SHLIB_RODATA_ADDR
  fi

The order should be:

  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
  fi

PR ld/22696
* scripttempl/elf.sc: Fix the order of SHLIB_RODATA_ADDR.

ld/ChangeLog
ld/scripttempl/elf.sc

index 0545b6a29ce84872039b353462eaf445549b9ffa..c5085b179b9519574d5b28705fb173a9f11db34e 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/22696
+       * scripttempl/elf.sc: Fix the order of SHLIB_RODATA_ADDR.
+
 2018-01-09  Jim Wilson  <jimw@sifive.com>
 
        * testsuite/ld-elf/eh-frame-hdr.d (#xfail): Delete
index 841a831437eb441d22135944ce8ee9fb2e1def98..3de86b0fcf15b4b504669614fa013486a48337b7 100644 (file)
@@ -522,8 +522,8 @@ SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
     SHLIB_RODATA_ADDR="\
 SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
   else
-    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
     SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
+    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
   fi
   cat <<EOF
   /* Adjust the address for the rodata segment.  We want to adjust up to