3.13.0-21 - Add valgrind-3.13.0-separate-code.patch (#1600034)

This commit is contained in:
Mark Wielaard 2018-07-12 16:15:15 +02:00
parent 34cf85c163
commit 91f5342839
2 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,93 @@
commit 3bce9544deab0261c7c55ccdc46ce1f36e468040
Author: Mark Wielaard <mark@klomp.org>
Date: Thu Jul 12 13:56:00 2018 +0200
Accept read-only PT_LOAD segments and .rodata.
The new binutils ld -z separate-code option creates multiple read-only
PT_LOAD segments and might place .rodata in a non-executable segment.
Allow and keep track of separate read-only segments and allow a readonly
page with .rodata section.
Based on patches from Tom Hughes <tom@compton.nu> and
H.J. Lu <hjl.tools@gmail.com>.
https://bugs.kde.org/show_bug.cgi?id=395682
index 13991b6..c36d498 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -1126,9 +1126,7 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd )
# error "Unknown platform"
# endif
-# if defined(VGP_x86_darwin) && DARWIN_VERS >= DARWIN_10_7
is_ro_map = seg->hasR && !seg->hasW && !seg->hasX;
-# endif
# if defined(VGO_solaris)
is_rx_map = seg->hasR && seg->hasX && !seg->hasW;
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index 62192f0..95b97d6 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -1881,7 +1881,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
Bool loaded = False;
for (j = 0; j < VG_(sizeXA)(di->fsm.maps); j++) {
const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
- if ( (map->rx || map->rw)
+ if ( (map->rx || map->rw || map->ro)
&& map->size > 0 /* stay sane */
&& a_phdr.p_offset >= map->foff
&& a_phdr.p_offset < map->foff + map->size
@@ -1912,6 +1912,16 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
i, (UWord)item.bias);
loaded = True;
}
+ if (map->ro
+ && (a_phdr.p_flags & (PF_R | PF_W | PF_X))
+ == PF_R) {
+ item.exec = False;
+ VG_(addToXA)(svma_ranges, &item);
+ TRACE_SYMTAB(
+ "PT_LOAD[%ld]: acquired as ro, bias 0x%lx\n",
+ i, (UWord)item.bias);
+ loaded = True;
+ }
}
}
if (!loaded) {
@@ -2179,17 +2189,25 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
}
}
- /* Accept .rodata where mapped as rx (data), even if zero-sized */
+ /* Accept .rodata where mapped as rx or rw (data), even if zero-sized */
if (0 == VG_(strcmp)(name, ".rodata")) {
- if (inrx && !di->rodata_present) {
- di->rodata_present = True;
+ if (!di->rodata_present) {
di->rodata_svma = svma;
- di->rodata_avma = svma + inrx->bias;
+ di->rodata_avma = svma;
di->rodata_size = size;
- di->rodata_bias = inrx->bias;
di->rodata_debug_svma = svma;
- di->rodata_debug_bias = inrx->bias;
- /* NB was 'inrw' prior to r11794 */
+ if (inrx) {
+ di->rodata_avma += inrx->bias;
+ di->rodata_bias = inrx->bias;
+ di->rodata_debug_bias = inrx->bias;
+ } else if (inrw) {
+ di->rodata_avma += inrw->bias;
+ di->rodata_bias = inrw->bias;
+ di->rodata_debug_bias = inrw->bias;
+ } else {
+ BAD(".rodata");
+ }
+ di->rodata_present = True;
TRACE_SYMTAB("acquiring .rodata svma = %#lx .. %#lx\n",
di->rodata_svma,
di->rodata_svma + di->rodata_size - 1);

View File

@ -181,6 +181,10 @@ Patch21: valgrind-3.13.0-build-id-phdrs.patch
# KDE#368913 WARNING: unhandled arm64-linux syscall: 117 (ptrace)
Patch22: valgrind-3.13.0-arm64-ptrace.patch
# RHBZ#1600034 KDE#395682
# Accept read-only PT_LOAD segments and .rodata created by ld -z separate-code.
Patch23: valgrind-3.13.0-ld-separate-code.patch
%if %{build_multilib}
# Ensure glibc{,-devel} is installed for both multilib arches
BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so
@ -323,6 +327,7 @@ Valgrind User Manual for details.
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%build
CC=gcc
@ -545,6 +550,9 @@ echo ===============END TESTING===============
%endif
%changelog
* Thu Jul 15 2018 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-21
- Add valgrind-3.13.0-separate-code.patch (#1600034)
* Thu Jul 5 2018 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-20
- Don't try a full_regtest under scl, also don't adjust PATH.