blob: 9e607b815b52e9d7c7d00283bee235e952b0f9d2 [file] [log] [blame]
nethercote4388a402004-09-01 23:20:49 +00001
njn7375de32009-08-05 08:08:18 +00002SUBDIRS = . tests
nethercote4388a402004-09-01 23:20:49 +00003
nethercoteb35a8b92004-09-11 16:45:27 +00004include $(top_srcdir)/Makefile.all.am
njn717cde52005-05-10 02:47:21 +00005
njn8b68b642009-06-24 00:37:09 +00006#----------------------------------------------------------------------------
7# <tool>-<platform> stuff
8#----------------------------------------------------------------------------
9
10TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@ = \
11 $(top_builddir)/coregrind/libcoregrind-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a \
12 $(top_builddir)/VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
13if VGCONF_HAVE_PLATFORM_SEC
14TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@ = \
15 $(top_builddir)/coregrind/libcoregrind-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a \
16 $(top_builddir)/VEX/libvex-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
17endif
18
19
20TOOL_LDADD_COMMON = -lgcc
21TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@ = \
22 $(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@) $(TOOL_LDADD_COMMON)
23if VGCONF_HAVE_PLATFORM_SEC
24TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@ = \
25 $(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@) $(TOOL_LDADD_COMMON)
26endif
27
28
29TOOL_LDFLAGS_COMMON_LINUX = -static \
30 -Wl,-defsym,valt_load_address=@VALT_LOAD_ADDRESS@ \
31 -nodefaultlibs -nostartfiles -u _start
32TOOL_LDFLAGS_COMMON_AIX5 = -static -Wl,-e_start_valgrind
33TOOL_LDFLAGS_COMMON_DARWIN = -nodefaultlibs -nostartfiles \
34 -Wl,-u,__start -Wl,-e,__start -Wl,-bind_at_load /usr/lib/dyld
35
36TOOL_LDFLAGS_X86_LINUX = \
37 $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@ \
38 -Wl,-T,$(top_builddir)/valt_load_address_x86_linux.lds
39
40TOOL_LDFLAGS_AMD64_LINUX = \
41 $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ \
42 -Wl,-T,$(top_builddir)/valt_load_address_amd64_linux.lds
43
44TOOL_LDFLAGS_PPC32_LINUX = \
45 $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@ \
46 -Wl,-T,$(top_builddir)/valt_load_address_ppc32_linux.lds
47
48TOOL_LDFLAGS_PPC64_LINUX = \
49 $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ \
50 -Wl,-T,$(top_builddir)/valt_load_address_ppc64_linux.lds
51
sewardj59570ff2010-01-01 11:59:33 +000052TOOL_LDFLAGS_ARM_LINUX = \
53 $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@ \
54 -Wl,-T,$(top_builddir)/valt_load_address_arm_linux.lds
55
njn8b68b642009-06-24 00:37:09 +000056TOOL_LDFLAGS_PPC32_AIX5 = \
57 $(TOOL_LDFLAGS_COMMON_AIX5) @FLAG_MAIX32@
58
59TOOL_LDFLAGS_PPC64_AIX5 = \
60 $(TOOL_LDFLAGS_COMMON_AIX5) @FLAG_MAIX64@ -Wl,-bbigtoc
61
62TOOL_LDFLAGS_X86_DARWIN = \
63 $(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386 \
64 -Wl,-seg1addr,0xf0080000 \
65 -Wl,-stack_addr,0xf0080000 -Wl,-stack_size,0x80000 \
66 -Wl,-pagezero_size,0xf0000000
67
68# pagezero can't be unmapped and remapped. Use stack instead.
69# GrP fixme no stack guard
70TOOL_LDFLAGS_AMD64_DARWIN = \
71 $(TOOL_LDFLAGS_COMMON_DARWIN) -arch x86_64 \
72 -Wl,-seg1addr,0x7fff55000000 \
73 -Wl,-stack_addr,0x7fff50080000 -Wl,-stack_size,0x7ffe50080000 \
74 -Wl,-pagezero_size,0x100000000
75
76
77BUILT_SOURCES =
78CLEANFILES =
79if VGCONF_PLATFORMS_INCLUDE_X86_LINUX
80BUILT_SOURCES += $(top_builddir)/valt_load_address_x86_linux.lds
81CLEANFILES += $(top_builddir)/valt_load_address_x86_linux.lds
82endif
83if VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX
84BUILT_SOURCES += $(top_builddir)/valt_load_address_amd64_linux.lds
85CLEANFILES += $(top_builddir)/valt_load_address_amd64_linux.lds
86endif
87if VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX
88BUILT_SOURCES += $(top_builddir)/valt_load_address_ppc32_linux.lds
89CLEANFILES += $(top_builddir)/valt_load_address_ppc32_linux.lds
90endif
91if VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX
92BUILT_SOURCES += $(top_builddir)/valt_load_address_ppc64_linux.lds
93CLEANFILES += $(top_builddir)/valt_load_address_ppc64_linux.lds
94endif
sewardj59570ff2010-01-01 11:59:33 +000095if VGCONF_PLATFORMS_INCLUDE_ARM_LINUX
96BUILT_SOURCES += $(top_builddir)/valt_load_address_arm_linux.lds
97CLEANFILES += $(top_builddir)/valt_load_address_arm_linux.lds
98endif
njn8b68b642009-06-24 00:37:09 +000099if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
100# No need to generate $(top_builddir)/valt_load_address*.lds; the final
101# executables can be linked to be at any address. They will be relocated by
102# AIX kernel when they are loaded.
103endif
104if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
105# Ditto
106endif
107if VGCONF_OS_IS_DARWIN
108# GrP untested, possibly hopeless
109endif
110
111
112# Generate a linker script for linking the binaries. This is the
113# standard gcc linker script, except hacked so that an alternative
114# load address can be specified by (1) asking gcc to use this script
115# (-Wl,-T,valt_load_address.lds) and (2) setting the symbol
116# valt_load_address to the required value
117# (-Wl,-defsym,valt_load_address=0x70000000).
118#
119# Extract ld's default linker script and hack it to our needs.
120# First we cut everything above and below the "=====..." lines at the top
121# and bottom.
122# Then we have to replace the load address with "valt_load_address".
123# The line to replace in has one of the following two forms:
124#
125# . = 0x08048000 + SIZEOF_HEADERS;
126#
127# or
128# PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
129#
130# So we search for the line with a hex value "+ SIZEOF_HEADERS", and replace
131# all the hex values in that line with "valt_load_address".
132$(top_builddir)/valt_load_address_x86_linux.lds: Makefile
133 $(CC) @FLAG_M32@ -Wl,--verbose -nostdlib 2>&1 | sed \
134 -e '1,/^=====\+$$/d' \
135 -e '/^=====\+$$/,/.\*/d' \
136 -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
137 || rm -f $@
138
139$(top_builddir)/valt_load_address_amd64_linux.lds: Makefile
140 $(CC) -m64 -Wl,--verbose -nostdlib 2>&1 | sed \
141 -e '1,/^=====\+$$/d' \
142 -e '/^=====\+$$/,/.\*/d' \
143 -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
144 || rm -f $@
145
146$(top_builddir)/valt_load_address_ppc32_linux.lds: Makefile
147 $(CC) @FLAG_M32@ -Wl,--verbose -nostdlib 2>&1 | sed \
148 -e '1,/^=====\+$$/d' \
149 -e '/^=====\+$$/,/.\*/d' \
150 -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
151 || rm -f $@
152
153$(top_builddir)/valt_load_address_ppc64_linux.lds: Makefile
154 $(CC) -m64 -Wl,--verbose -nostdlib 2>&1 | sed \
155 -e '1,/^=====\+$$/d' \
156 -e '/^=====\+$$/,/.\*/d' \
157 -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
158 || rm -f $@
159
sewardj59570ff2010-01-01 11:59:33 +0000160$(top_builddir)/valt_load_address_arm_linux.lds: Makefile
161 $(CC) @FLAG_M32@ -Wl,--verbose -nostdlib 2>&1 | sed \
162 -e '1,/^=====\+$$/d' \
163 -e '/^=====\+$$/,/.\*/d' \
164 -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
165 || rm -f $@
166
njn8b68b642009-06-24 00:37:09 +0000167#----------------------------------------------------------------------------
168# vgpreload_<tool>-<platform>.a stuff
169#----------------------------------------------------------------------------
njnb7fda4c2009-02-06 04:05:43 +0000170
tomfb7bcde2005-11-07 15:24:38 +0000171LIBREPLACEMALLOC_X86_LINUX = \
sewardj4d3f7a42009-02-22 23:40:31 +0000172 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-linux.a
sewardj45f4e7c2005-09-27 19:20:21 +0000173
tomfb7bcde2005-11-07 15:24:38 +0000174LIBREPLACEMALLOC_AMD64_LINUX = \
sewardj4d3f7a42009-02-22 23:40:31 +0000175 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-linux.a
tomfb7bcde2005-11-07 15:24:38 +0000176
177LIBREPLACEMALLOC_PPC32_LINUX = \
sewardj4d3f7a42009-02-22 23:40:31 +0000178 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc32-linux.a
tomfb7bcde2005-11-07 15:24:38 +0000179
sewardj2c48c7b2005-11-29 13:05:56 +0000180LIBREPLACEMALLOC_PPC64_LINUX = \
sewardj4d3f7a42009-02-22 23:40:31 +0000181 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc64-linux.a
sewardj2c48c7b2005-11-29 13:05:56 +0000182
sewardj59570ff2010-01-01 11:59:33 +0000183LIBREPLACEMALLOC_ARM_LINUX = \
184 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm-linux.a
185
sewardj1eff82b2006-10-17 00:56:43 +0000186LIBREPLACEMALLOC_PPC32_AIX5 = \
sewardj4d3f7a42009-02-22 23:40:31 +0000187 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc32-aix5.a
sewardj1eff82b2006-10-17 00:56:43 +0000188
189LIBREPLACEMALLOC_PPC64_AIX5 = \
sewardj4d3f7a42009-02-22 23:40:31 +0000190 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc64-aix5.a
sewardj1eff82b2006-10-17 00:56:43 +0000191
njnf76d27a2009-05-28 01:53:07 +0000192LIBREPLACEMALLOC_X86_DARWIN = \
193 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-darwin.a
194
195LIBREPLACEMALLOC_AMD64_DARWIN = \
196 $(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-darwin.a
197
njnb7fda4c2009-02-06 04:05:43 +0000198
tomfb7bcde2005-11-07 15:24:38 +0000199LIBREPLACEMALLOC_LDFLAGS_X86_LINUX = \
200 -Wl,--whole-archive \
201 $(LIBREPLACEMALLOC_X86_LINUX) \
202 -Wl,--no-whole-archive
njnb7fda4c2009-02-06 04:05:43 +0000203
tomfb7bcde2005-11-07 15:24:38 +0000204LIBREPLACEMALLOC_LDFLAGS_AMD64_LINUX = \
205 -Wl,--whole-archive \
206 $(LIBREPLACEMALLOC_AMD64_LINUX) \
207 -Wl,--no-whole-archive
njnb7fda4c2009-02-06 04:05:43 +0000208
tomfb7bcde2005-11-07 15:24:38 +0000209LIBREPLACEMALLOC_LDFLAGS_PPC32_LINUX = \
210 -Wl,--whole-archive \
211 $(LIBREPLACEMALLOC_PPC32_LINUX) \
212 -Wl,--no-whole-archive
njnb7fda4c2009-02-06 04:05:43 +0000213
sewardj2c48c7b2005-11-29 13:05:56 +0000214LIBREPLACEMALLOC_LDFLAGS_PPC64_LINUX = \
215 -Wl,--whole-archive \
216 $(LIBREPLACEMALLOC_PPC64_LINUX) \
217 -Wl,--no-whole-archive
njnb7fda4c2009-02-06 04:05:43 +0000218
sewardj59570ff2010-01-01 11:59:33 +0000219LIBREPLACEMALLOC_LDFLAGS_ARM_LINUX = \
220 -Wl,--whole-archive \
221 $(LIBREPLACEMALLOC_ARM_LINUX) \
222 -Wl,--no-whole-archive
223
sewardj1eff82b2006-10-17 00:56:43 +0000224LIBREPLACEMALLOC_LDFLAGS_PPC32_AIX5 = \
225 $(LIBREPLACEMALLOC_PPC32_AIX5)
njnb7fda4c2009-02-06 04:05:43 +0000226
sewardj1eff82b2006-10-17 00:56:43 +0000227LIBREPLACEMALLOC_LDFLAGS_PPC64_AIX5 = \
228 $(LIBREPLACEMALLOC_PPC64_AIX5)
njn3e653402009-02-06 07:12:57 +0000229
njnf76d27a2009-05-28 01:53:07 +0000230LIBREPLACEMALLOC_LDFLAGS_X86_DARWIN = \
231 $(LIBREPLACEMALLOC_X86_DARWIN)
njn3e653402009-02-06 07:12:57 +0000232
njnf76d27a2009-05-28 01:53:07 +0000233LIBREPLACEMALLOC_LDFLAGS_AMD64_DARWIN = \
234 $(LIBREPLACEMALLOC_AMD64_DARWIN)
njnac31b052009-02-12 00:30:02 +0000235
njn8b68b642009-06-24 00:37:09 +0000236#----------------------------------------------------------------------------
237# General stuff
238#----------------------------------------------------------------------------
njnf76d27a2009-05-28 01:53:07 +0000239
240all-local: inplace-noinst_PROGRAMS inplace-noinst_DSYMS
241
242clean-local: clean-noinst_DSYMS
243
244install-exec-local: install-noinst_PROGRAMS install-noinst_DSYMS
njnac31b052009-02-12 00:30:02 +0000245