From 5ed1ef2bb8f98375c37e25f0c3d2374ae238b9de Mon Sep 17 00:00:00 2001 From: kichik Date: Wed, 22 Jun 2005 14:49:34 +0000 Subject: [PATCH] added linker script to assure correct order of sections git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4122 212acab6-be3b-0410-9dea-997c60f758d6 --- SCons/Config/gnu | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/SCons/Config/gnu b/SCons/Config/gnu index 8cc6e2ad..e0733090 100644 --- a/SCons/Config/gnu +++ b/SCons/Config/gnu @@ -80,6 +80,32 @@ util_env.Append(LINKFLAGS = '$ALIGN_FLAG') # 512 bytes align ### weird GCC requirements +# +# GCC puts new PE sections, added by code, between other sections. +# This is not good for the .ndata section because makensis changes +# its size dynamically. This is not good if RVAs to sections below +# it are saved in other places. The RVAs will point to garbage. +# +# To fix this, a linker script is provided. The linker script makes +# sure the sections will be written in the correct order. +# + +script_path = File('#.sconf_temp/linker_script').path +open(script_path, 'w').write(""" + SECTIONS + { + .text : { *(.text) } + .data : { *(.data) } + .rdata : { *(.rdata) } + .bss : { *(.bss) } + .idata : { *(.idata) } + .ndata BLOCK(__section_alignment__) : { [ .ndata ] } + .rsrc : { *(.rsrc) } + } +""") + +stub_env.Append(LINKFLAGS = '-Wl,%s' % script_path) + # # GCC requires some functions from the CRT to be present, if certain # operations are done. For example, if a small string is assigned to