From a0a6af28547acf3b69e0e5ee379c727e8a3cfa0b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sat, 18 Jun 2005 16:41:30 +0000 Subject: [PATCH] Make the stage2.lds building platform-independent by not trying to match an exact address (idea from Paul Mackerras' PPC port). Thus it could be moved into coregrind/Makefile.am. Let me know if this breaks anything on other platforms. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3939 --- coregrind/Makefile.am | 17 +++++++++++++++-- coregrind/amd64/Makefile.am | 9 --------- coregrind/arm/Makefile.am | 9 --------- coregrind/x86/Makefile.am | 9 --------- memcheck/tests/Makefile.am | 4 ++-- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index be6ea6799..214c26712 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -83,6 +83,9 @@ EXTRA_DIST = \ valgrind.vs \ README_MODULES.txt +BUILT_SOURCES = stage2.lds +CLEANFILES = stage2.lds + valgrind_SOURCES = \ ume.c \ \ @@ -159,11 +162,11 @@ stage2_LDFLAGS = \ -Wl,--whole-archive $(stage2_extra2) -Wl,--no-whole-archive \ -pie else -stage2_DEPENDENCIES = $(st2_DEPS_common) ${VG_ARCH}/stage2.lds +stage2_DEPENDENCIES = $(st2_DEPS_common) stage2.lds stage2_LDFLAGS = \ $(st2_LDFLAGS_common) \ -Wl,--whole-archive $(stage2_extra2) -Wl,--no-whole-archive \ - -Wl,-defsym,kickstart_base=@KICKSTART_BASE@ -Wl,-T,${VG_ARCH}/stage2.lds + -Wl,-defsym,kickstart_base=@KICKSTART_BASE@ -Wl,-T,stage2.lds endif stage2_LDADD= $(stage2_extra) \ @@ -177,6 +180,16 @@ vg_preload_core_so_LDFLAGS = \ -Wl,--soname,vg_preload_core.so \ -Wl,-z,initfirst +# Extract ld's default linker script and hack it to our needs. +# This relies on finding "executable_start" and replacing the address on +# that line with kickstart_base. +stage2.lds: Makefile + $(CC) -Wl,--verbose -nostdlib 2>&1 | sed \ + -e '1,/^=====\+$$/d' \ + -e '/^=====\+$$/d' \ + -e '/executable_start/s/0x[0-9A-Fa-f]\+/kickstart_base/g' > $@ \ + || rm -f $@ + MANUAL_DEPS = $(noinst_HEADERS) $(include_HEADERS) all-local: diff --git a/coregrind/amd64/Makefile.am b/coregrind/amd64/Makefile.am index ff0495287..8306f657e 100644 --- a/coregrind/amd64/Makefile.am +++ b/coregrind/amd64/Makefile.am @@ -3,15 +3,6 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_LIBRARIES = libarch.a -BUILT_SOURCES = stage2.lds -CLEANFILES = stage2.lds - libarch_a_SOURCES = \ cpuid.S -# Extract ld's default linker script and hack it to our needs -stage2.lds: Makefile - $(CC) -Wl,--verbose -nostdlib 2>&1 | sed \ - -e '1,/^=====\+$$/d' \ - -e '/^=====\+$$/d' \ - -e 's/0x400000/kickstart_base/g' > $@ || rm -f $@ diff --git a/coregrind/arm/Makefile.am b/coregrind/arm/Makefile.am index 3b0144aaf..da669e952 100644 --- a/coregrind/arm/Makefile.am +++ b/coregrind/arm/Makefile.am @@ -3,14 +3,5 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_LIBRARIES = libarch.a -BUILT_SOURCES = stage2.lds -CLEANFILES = stage2.lds - libarch_a_SOURCES = -# Extract ld's default linker script and hack it to our needs -stage2.lds: Makefile - $(CC) -Wl,--verbose -nostdlib 2>&1 | sed \ - -e '1,/^=====\+$$/d' \ - -e '/^=====\+$$/d' \ - -e 's/0x00008000/kickstart_base/g' > $@ || rm -f $@ diff --git a/coregrind/x86/Makefile.am b/coregrind/x86/Makefile.am index 72a381fb3..8306f657e 100644 --- a/coregrind/x86/Makefile.am +++ b/coregrind/x86/Makefile.am @@ -3,15 +3,6 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am noinst_LIBRARIES = libarch.a -BUILT_SOURCES = stage2.lds -CLEANFILES = stage2.lds - libarch_a_SOURCES = \ cpuid.S -# Extract ld's default linker script and hack it to our needs -stage2.lds: Makefile - $(CC) $(AM_CFLAGS) -Wl,--verbose -nostdlib 2>&1 | sed \ - -e '1,/^=====\+$$/d' \ - -e '/^=====\+$$/d' \ - -e 's/0x08048000/kickstart_base/g' > $@ || rm -f $@ diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 588dcff5b..62faa6d9d 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -196,8 +196,8 @@ hello_CFLAGS = $(AM_CFLAGS) -fpie hello_LDFLAGS = -pie else hello_LDFLAGS = -Wl,-defsym,kickstart_base=0x50000000 \ - -Wl,-T,../../coregrind/${VG_ARCH}/stage2.lds -hello_DEPENDENCIES = ../../coregrind/${VG_ARCH}/stage2.lds + -Wl,-T,../../coregrind/stage2.lds +hello_DEPENDENCIES = ../../coregrind/stage2.lds endif vgtest_ume_CFLAGS = -DVGA_$(VG_ARCH)