[1/2] coff-go32: update ldscript

Message ID 20200408152104.891-2-jwjagersma@gmail.com
State New
Headers show
Series
  • djgpp patches
Related show

Commit Message

H.J. Lu via Binutils April 8, 2020, 3:21 p.m.
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(+)

-- 
2.26.0

Patch

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) }