patch from Fedora to fix "Unsupported arch_prctl option"; rel 3
[packages/valgrind.git] / valgrind-3.13.0-ld-separate-code.patch
CommitLineData
aa32c533
AM
1commit 3bce9544deab0261c7c55ccdc46ce1f36e468040
2Author: Mark Wielaard <mark@klomp.org>
3Date: Thu Jul 12 13:56:00 2018 +0200
4
5 Accept read-only PT_LOAD segments and .rodata.
6
7 The new binutils ld -z separate-code option creates multiple read-only
8 PT_LOAD segments and might place .rodata in a non-executable segment.
9
10 Allow and keep track of separate read-only segments and allow a readonly
11 page with .rodata section.
12
13 Based on patches from Tom Hughes <tom@compton.nu> and
14 H.J. Lu <hjl.tools@gmail.com>.
15
16 https://bugs.kde.org/show_bug.cgi?id=395682
17
18index 13991b6..c36d498 100644
19--- a/coregrind/m_debuginfo/debuginfo.c
20+++ b/coregrind/m_debuginfo/debuginfo.c
21@@ -1126,9 +1126,7 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd )
22 # error "Unknown platform"
23 # endif
24
25-# if defined(VGP_x86_darwin) && DARWIN_VERS >= DARWIN_10_7
26 is_ro_map = seg->hasR && !seg->hasW && !seg->hasX;
27-# endif
28
29 # if defined(VGO_solaris)
30 is_rx_map = seg->hasR && seg->hasX && !seg->hasW;
31diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
32index 62192f0..95b97d6 100644
33--- a/coregrind/m_debuginfo/readelf.c
34+++ b/coregrind/m_debuginfo/readelf.c
35@@ -1881,7 +1881,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
36 Bool loaded = False;
37 for (j = 0; j < VG_(sizeXA)(di->fsm.maps); j++) {
38 const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
39- if ( (map->rx || map->rw)
40+ if ( (map->rx || map->rw || map->ro)
41 && map->size > 0 /* stay sane */
42 && a_phdr.p_offset >= map->foff
43 && a_phdr.p_offset < map->foff + map->size
44@@ -1912,6 +1912,16 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
45 i, (UWord)item.bias);
46 loaded = True;
47 }
48+ if (map->ro
49+ && (a_phdr.p_flags & (PF_R | PF_W | PF_X))
50+ == PF_R) {
51+ item.exec = False;
52+ VG_(addToXA)(svma_ranges, &item);
53+ TRACE_SYMTAB(
54+ "PT_LOAD[%ld]: acquired as ro, bias 0x%lx\n",
55+ i, (UWord)item.bias);
56+ loaded = True;
57+ }
58 }
59 }
60 if (!loaded) {
61@@ -2179,17 +2189,25 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
62 }
63 }
64
65- /* Accept .rodata where mapped as rx (data), even if zero-sized */
66+ /* Accept .rodata where mapped as rx or rw (data), even if zero-sized */
67 if (0 == VG_(strcmp)(name, ".rodata")) {
68- if (inrx && !di->rodata_present) {
69- di->rodata_present = True;
70+ if (!di->rodata_present) {
71 di->rodata_svma = svma;
72- di->rodata_avma = svma + inrx->bias;
73+ di->rodata_avma = svma;
74 di->rodata_size = size;
75- di->rodata_bias = inrx->bias;
76 di->rodata_debug_svma = svma;
77- di->rodata_debug_bias = inrx->bias;
78- /* NB was 'inrw' prior to r11794 */
79+ if (inrx) {
80+ di->rodata_avma += inrx->bias;
81+ di->rodata_bias = inrx->bias;
82+ di->rodata_debug_bias = inrx->bias;
83+ } else if (inrw) {
84+ di->rodata_avma += inrw->bias;
85+ di->rodata_bias = inrw->bias;
86+ di->rodata_debug_bias = inrw->bias;
87+ } else {
88+ BAD(".rodata");
89+ }
90+ di->rodata_present = True;
91 TRACE_SYMTAB("acquiring .rodata svma = %#lx .. %#lx\n",
92 di->rodata_svma,
93 di->rodata_svma + di->rodata_size - 1);
This page took 0.036696 seconds and 4 git commands to generate.