[PATCH 1/2] coff-go32: update ldscript

J.W. Jagersma jwjagersma@gmail.com
Wed Apr 8 15:21:03 GMT 2020


This patch updates the linker scripts for coff-go32.
Most importantly, it defines the _environ symbol.  Without this it is
impossible to link any program with djgpp's libc, since it requires
this symbol to be provided by the linker script.
Also the .ctors and .dtors sections are linked in, and finally the LTO
sections are discarded.

ld/
2020-04-08  Juan Manuel Guerrero  <juan.guerrero@gmx.de>
            Jan W. Jagersma  <jwjagersma@gmail.com>

	* scripttempl/i386go32.sc: Provide symbol _environ.  Link in
	.ctors and .dtors.  Discard LTO sections.
---
 ld/scripttempl/i386go32.sc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ld/scripttempl/i386go32.sc b/ld/scripttempl/i386go32.sc
index 999aa0527d..feb919b982 100644
--- a/ld/scripttempl/i386go32.sc
+++ b/ld/scripttempl/i386go32.sc
@@ -47,11 +47,16 @@ SECTIONS
     ${RELOCATING+djgpp_first_ctor = . ;
     *(SORT(.ctors.*))
     *(.ctor)
+    *(.ctors)
     djgpp_last_ctor = . ;}
     ${RELOCATING+djgpp_first_dtor = . ;
     *(SORT(.dtors.*))
     *(.dtor)
+    *(.dtors)
     djgpp_last_dtor = . ;}
+    __environ = . ;
+    PROVIDE(_environ = .) ;
+    LONG(0) ;
     *(.data)
     ${RELOCATING+*(.data.*)}
 
@@ -74,6 +79,8 @@ SECTIONS
     ${RELOCATING+ end = . ; PROVIDE(_end = .) ;}
     ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});}
   }
+  /* Discard LTO sections.  */
+  /DISCARD/ : { *(.gnu.lto_*) }
   /* Stabs debugging sections.  */
   .stab 0 : { *(.stab) }
   .stabstr 0 : { *(.stabstr) }
-- 
2.26.0



More information about the Binutils mailing list