]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
v850: improve linker scripts for relocatable linking
authorJan Beulich <jbeulich@suse.com>
Fri, 7 Mar 2025 07:29:20 +0000 (08:29 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 7 Mar 2025 07:29:20 +0000 (08:29 +0100)
Quite a few constructs where unconditional when they should take
$RELOCATING into account. The original observation was that output of
"ld -r" had .text start at 0x00100000.

ld/scripttempl/v850.sc
ld/scripttempl/v850_rh850.sc

index d005818627d544b17f56a019e74eb819bfd72cf9..c7f79216e9ca0b2b461d430a03ec6de81c9a3dca 100644 (file)
@@ -26,7 +26,7 @@ SECTIONS
   /* This saves a little space in the ELF file, since the zda starts
      at a higher location that the ELF headers take up.  */
 
-  .zdata ${ZDATA_START_ADDR} :
+  .zdata ${RELOCATING+${ZDATA_START_ADDR}} :
   {
        *(.zdata)
        ${RELOCATING+*(.zbss)
@@ -40,7 +40,7 @@ SECTIONS
      section.  Specifically it prevents the zdata
      section from being marked READONLY.  */
 
-  .rozdata ${ROZDATA_START_ADDR} :
+  .rozdata ${RELOCATING+${ROZDATA_START_ADDR}} :
   {
        *(.rozdata)
        ${RELOCATING+*(romzdata)
@@ -48,7 +48,7 @@ SECTIONS
   }
 
   /* Read-only sections, merged into text segment.  */
-  . = ${TEXT_START_ADDR};
+  ${RELOCATING+. = ${TEXT_START_ADDR};}
   .interp      : { *(.interp) }
   .hash                : { *(.hash) }
   .dynsym      : { *(.dynsym) }
@@ -95,7 +95,7 @@ SECTIONS
       It contains a small lookup table at the start followed by the
       code pointed to by entries in the lookup table.  */
 
-  .call_table_data ${CALL_TABLE_START_ADDR} :
+  .call_table_data ${RELOCATING+${CALL_TABLE_START_ADDR}} :
   {
     ${RELOCATING+PROVIDE(__ctbp = .);}
     *(.call_table_data)
@@ -144,7 +144,7 @@ SECTIONS
   .got         : {${RELOCATING+ *(.got.plt)} *(.got) }
   .dynamic     : { *(.dynamic) }
 
-  .tdata ${TDATA_START_ADDR} :
+  .tdata ${RELOCATING+${TDATA_START_ADDR}} :
   {
        ${RELOCATING+PROVIDE (__ep = .);
        *(.tbyte)
@@ -158,14 +158,14 @@ SECTIONS
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
 
-  .sdata ${SDATA_START_ADDR} :
+  .sdata ${RELOCATING+${SDATA_START_ADDR}} :
   {
        ${RELOCATING+PROVIDE (__gp = . + 0x8000);}
        *(.sdata)
    }
 
   /* See comment about .rozdata. */
-  .rosdata ${ROSDATA_START_ADDR} :
+  .rosdata ${RELOCATING+${ROSDATA_START_ADDR}} :
   {
        *(.rosdata)
   }
index cfe25d2001bc5cdb75ff1378e7341ad9005e35f5..ad27769989f81dc5d3a0b027eab68e58504e5dcf 100644 (file)
@@ -26,7 +26,7 @@ SECTIONS
   /* This saves a little space in the ELF file, since the zda starts
      at a higher location that the ELF headers take up.  */
 
-  .zdata ${ZDATA_START_ADDR} :
+  .zdata ${RELOCATING+${ZDATA_START_ADDR}} :
   {
        *(.zdata)
        ${RELOCATING+*(.zdata23)
@@ -42,7 +42,7 @@ SECTIONS
      section.  Specifically it prevents the zdata
      section from being marked READONLY.  */
 
-  .rozdata ${ROZDATA_START_ADDR} :
+  .rozdata ${RELOCATING+${ROZDATA_START_ADDR}} :
   {
        *(.rozdata)
        ${RELOCATING+*(romzdata)
@@ -52,7 +52,7 @@ SECTIONS
   }
 
   /* Read-only sections, merged into text segment.  */
-  . = ${TEXT_START_ADDR};
+  ${RELOCATING+. = ${TEXT_START_ADDR};}
   .interp      : { *(.interp) }
   .hash                : { *(.hash) }
   .dynsym      : { *(.dynsym) }
@@ -99,7 +99,7 @@ SECTIONS
       It contains a small lookup table at the start followed by the
       code pointed to by entries in the lookup table.  */
 
-  .call_table_data ${CALL_TABLE_START_ADDR} :
+  .call_table_data ${RELOCATING+${CALL_TABLE_START_ADDR}} :
   {
     ${RELOCATING+PROVIDE(__ctbp = .);}
     *(.call_table_data)
@@ -154,7 +154,7 @@ SECTIONS
   .got         : {${RELOCATING+ *(.got.plt)} *(.got) }
   .dynamic     : { *(.dynamic) }
 
-  .tdata ${TDATA_START_ADDR} :
+  .tdata ${RELOCATING+${TDATA_START_ADDR}} :
   {
        ${RELOCATING+PROVIDE (__ep = .);
        *(.edata)
@@ -174,7 +174,7 @@ SECTIONS
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
 
-  .sdata ${SDATA_START_ADDR} :
+  .sdata ${RELOCATING+${SDATA_START_ADDR}} :
   {
        ${RELOCATING+PROVIDE (__gp = . + 0x8000);}
        *(.sdata)
@@ -182,7 +182,7 @@ SECTIONS
    }
 
   /* See comment about .rozdata. */
-  .rosdata ${ROSDATA_START_ADDR} :
+  .rosdata ${RELOCATING+${ROSDATA_START_ADDR}} :
   {
        *(.rosdata)
        ${RELOCATING+*(.sconst)