summaryrefslogtreecommitdiff
path: root/dev-util/valgrind/files/valgrind-3.17.0-lld.patch
blob: 56a7c0f72f46f5d6c000d9493ec4c1260bfbaf1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
https://bugs.kde.org/show_bug.cgi?id=439046
---
diff --git a/configure.ac b/configure.ac
index 4582fb5d0..63fd6c25e 100755
--- a/configure.ac
+++ b/configure.ac
@@ -2639,30 +2639,52 @@ CFLAGS=$safe_CFLAGS
 # will reside. -Ttext aligns just the .text section start (but not any
 # other section).
 #
-# So test for -Ttext-segment which is supported by all bfd ld versions
+# LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
+# in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
+# The --image-base option (since version 6.0?) provides the semantics needed.
+# -Ttext-segment generates an error, but -Ttext now more closely
+# follows the GNU (bfd) ld's -Ttext.
+#
+# So test first for --image-base support, and if that fails then
+# for -Ttext-segment which is supported by all bfd ld versions
 # and use that if it exists. If it doesn't exist it must be an older
 # version of gold and we can fall back to using -Ttext which has the
 # right semantics.
 
-AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
-
 safe_CFLAGS=$CFLAGS
-CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
+AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
+
+CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
 
 AC_LINK_IFELSE(
 [AC_LANG_SOURCE([int _start () { return 0; }])],
 [
   linker_using_t_text="no"
-  AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
+  AC_SUBST([FLAG_T_TEXT], ["--image-base"])
   AC_MSG_RESULT([yes])
 ], [
-  linker_using_t_text="yes"
-  AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
   AC_MSG_RESULT([no])
+
+  AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
+
+  CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
+
+  AC_LINK_IFELSE(
+  [AC_LANG_SOURCE([int _start () { return 0; }])],
+  [
+    linker_using_t_text="no"
+    AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
+    AC_MSG_RESULT([yes])
+  ], [
+    linker_using_t_text="yes"
+    AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
+    AC_MSG_RESULT([no])
+  ])
 ])
+
 CFLAGS=$safe_CFLAGS
 
-# If the linker only supports -Ttext (not -Ttext-segment) then we will
+# If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
 # have to strip any build-id ELF NOTEs from the statically linked tools.
 # Otherwise the build-id NOTE might end up at the default load address.
 # (Pedantically if the linker is gold then -Ttext is fine, but newer
@@ -2688,7 +2710,7 @@ AC_LINK_IFELSE(
   AC_MSG_RESULT([no])
 ])
 else
-AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
+AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
 AC_SUBST([FLAG_NO_BUILD_ID], [""])
 fi
 CFLAGS=$safe_CFLAGS
--