import dyninst-10.2.1-2.el8

This commit is contained in:
CentOS Sources 2021-03-30 11:10:40 -04:00 committed by Stepan Oksanichenko
parent 5bc679b84f
commit bd0b725c91
12 changed files with 431 additions and 371 deletions

View File

@ -1,2 +1,2 @@
02029d0224460f866f92ef54221efa37ee1ba164 SOURCES/dyninst-10.1.0.tar.gz
3e842456203d4702acd4771ae648f4cf382b9a12 SOURCES/dyninst-10.2.1.tar.gz
cbafd2da77de24180cb9c2fb5b600fd8d2cb2fa1 SOURCES/testsuite-10.1.0.tar.gz

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
SOURCES/dyninst-10.1.0.tar.gz
SOURCES/dyninst-10.2.1.tar.gz
SOURCES/testsuite-10.1.0.tar.gz

View File

@ -1,309 +0,0 @@
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/BPatch_addressSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/BPatch_addressSpace.C 2019-11-06 10:20:08.567523510 -0500
--- BPatch_addressSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
+++ BPatch_addressSpace.C 2019-11-15 18:10:31.186122654 -0500
@@ -1050,5 +1050,2 @@
return true;
-
- regs = registers_;
- return true;
}
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.C.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.C 2019-11-06 10:20:08.567523510 -0500
@@ -276,9 +276,2 @@
- if (register_num == REG_SP) {
- insnCodeGen::generateAddSubImmediate(gen, insnCodeGen::Add, 0,
- TRAMP_FRAME_SIZE_64, destination, REG_SP, true);
-
- return;
- }
-
if (src->spilledState == registerSlot::unspilled)
@@ -293,3 +286,3 @@
// its on the stack so load it.
- insnCodeGen::restoreRegister(gen, destination, offset + (register_num * gen.width()),
+ insnCodeGen::restoreRegister(gen, destination, offset + (src->encoding() * gen.width()),
insnCodeGen::Offset);
@@ -298 +291,7 @@
+bool EmitterAARCH64::emitMoveRegToReg(Register src, Register dest, codeGen &gen)
+{
+ insnCodeGen::generateMove(gen, dest, src);
+ return true;
+}
+
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.h.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.h 2019-11-06 10:20:08.567523510 -0500
@@ -107,6 +107,3 @@
- virtual bool emitMoveRegToReg(Register, Register, codeGen &) {
- assert(0);
- return 0;
- }
+ virtual bool emitMoveRegToReg(Register, Register, codeGen &);
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.C.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.C 2019-11-06 10:20:08.567523510 -0500
@@ -108,2 +108,4 @@
registers.push_back(new registerSlot(r30, "r30", true, registerSlot::liveAlways, registerSlot::GPR));
+ // SP is r31, but also could be considered special. But now it's being added as GPR
+ registers.push_back(new registerSlot(sp, "r31", true, registerSlot::liveAlways, registerSlot::GPR));
@@ -111,3 +113,3 @@
registers.push_back(new registerSlot(lr, "lr", true, registerSlot::liveAlways, registerSlot::SPR));
- registers.push_back(new registerSlot(sp, "sp", true, registerSlot::liveAlways, registerSlot::SPR));
+ //registers.push_back(new registerSlot(sp, "sp", true, registerSlot::liveAlways, registerSlot::SPR));
registers.push_back(new registerSlot(pstate, "nzcv", true, registerSlot::liveAlways, registerSlot::SPR));
@@ -183,9 +185,16 @@
registerSlot *reg = theRegSpace->GPRs()[idx];
- // We always save FP and LR for stack walking out of instrumentation
- if (reg->liveState == registerSlot::live || reg->number == REG_FP || reg->number == REG_LR) {
+ // We always save FP and LR for stack walking out of instrumentation
+ //if (reg->liveState == registerSlot::live || reg->number == REG_FP || reg->number == REG_LR) {
int offset_from_sp = offset + (reg->encoding() * gen.width());
- insnCodeGen::saveRegister(gen, reg->number, offset_from_sp);
+ if(reg->number != registerSpace::sp)
+ insnCodeGen::saveRegister(gen, reg->number, offset_from_sp);
+ else{
+ // mov SP to x0
+ insnCodeGen::generateAddSubImmediate(gen, insnCodeGen::Add, 0,
+ TRAMP_FRAME_SIZE_64, REG_SP, 0, true);
+ insnCodeGen::saveRegister(gen, 0, offset_from_sp);
+ }
theRegSpace->markSavedRegister(reg->number, offset_from_sp);
ret++;
- }
+ //}
}
@@ -283,2 +292,4 @@
if(reg->liveState == registerSlot::spilled) {
+ if(reg->number == registerSpace::sp)
+ continue;
//#sasha this should be GPRSIZE_64 and not gen.width
@@ -602,4 +613,2 @@
{
- //#sasha This function implementation is experimental.
-
if (op != callOp) {
@@ -623,4 +632,2 @@
vector<int> savedRegs;
-
- // save r0-r7
for(size_t id = 0; id < gen.rs()->numGPRs(); id++)
@@ -653,2 +660,6 @@
assert(reg!=REG_NULL);
+
+ // mark reg offLimits so getScratchRegister won't use it
+ registerSlot *regS = gen.rs()->GPRs()[id];
+ regS->offLimits = true;
}
@@ -691,3 +702,2 @@
- // r7-r0
for (signed int ui = savedRegs.size()-1; ui >= 0; ui--) {
@@ -697,2 +707,9 @@
+ // Making operand's reg not offLimits again
+ for(size_t id = 0; id < operands.size(); id++)
+ {
+ registerSlot *reg = gen.rs()->GPRs()[id];
+ reg->offLimits = false;
+ }
+
return 0;
@@ -1426,4 +1443,53 @@
bool EmitterAARCH64Stat::emitPLTCall(func_instance *callee, codeGen &gen) {
- assert(0); //Not implemented
- return emitPLTCommon(callee, true, gen);
+ /*
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ //Register scr = gen.rs()->getScratchRegister(gen);
+ //Register lr = gen.rs()->getScratchRegister(gen);
+ //Address pc = emitMovePCToReg(scr, gen);
+
+ Address varOffset = dest - gen.currAddr();
+ //printf("VarOffset = %d\n", varOffset);
+ //emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+
+ insnCodeGen::generateBranch(gen, gen.currAddr(), dest, true);
+
+ return true;
+ */
+
+
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ Register scr = gen.rs()->getScratchRegister(gen);
+ Register lr = gen.rs()->getScratchRegister(gen);
+ //Register scr = gen.rs()->getRegByName("r2");
+ //Register lr = gen.rs()->getRegByName("r3");
+ emitMovePCToReg(scr, gen);
+
+ Address varOffset = dest - gen.currAddr() + 4;
+ //printf("VarOffset = %d\n", varOffset);
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
+
+ // indirect branch
+ instruction branchInsn;
+ branchInsn.clear();
+
+ //Set bits which are 0 for both BR and BLR
+ INSN_SET(branchInsn, 0, 4, 0);
+ INSN_SET(branchInsn, 10, 15, 0);
+
+ //Set register
+ INSN_SET(branchInsn, 5, 9, lr);
+
+ //Set other bits. Basically, these are the opcode bits.
+ //The only difference between BR and BLR is that bit 21 is 1 for BLR.
+ INSN_SET(branchInsn, 16, 31, BRegOp);
+ INSN_SET(branchInsn, 21, 21, 1);
+ insnCodeGen::generate(gen, branchInsn);
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), lr, true);
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, true);
+
+ return true;
+
+ //assert(0); //Not implemented
+ //return emitPLTCommon(callee, true, gen);
}
@@ -1431,4 +1497,81 @@
bool EmitterAARCH64Stat::emitPLTJump(func_instance *callee, codeGen &gen) {
- assert(0); //Not implemented
- return emitPLTCommon(callee, false, gen);
+ /*
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ //Register scr = gen.rs()->getScratchRegister(gen);
+ //Register lr = gen.rs()->getScratchRegister(gen);
+ Register scr = gen.rs()->getRegByName("r2");
+ Register lr = gen.rs()->getRegByName("r3");
+ //Address pc = emitMovePCToReg(scr, gen);
+
+ Address varOffset = dest - gen.currAddr();
+ //printf("VarOffset = %d\n", varOffset);
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
+
+ insnCodeGen::generateBranch(gen, gen.currAddr(), lr, false);
+
+ return true;
+ */
+
+ /*
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ Register scr = gen.rs()->getScratchRegister(gen);
+ Register lr = gen.rs()->getScratchRegister(gen);
+ Address pc = emitMovePCToReg(scr, gen);
+
+ Address varOffset = dest - pc;
+ printf("VarOffset = %d\n", varOffset);
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+
+ insnCodeGen::generateBranch(gen, gen.currAddr(), lr, false);
+ return true;
+ */
+
+ /*
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ Register scr = gen.rs()->getScratchRegister(gen);
+ Register lr = gen.rs()->getScratchRegister(gen);
+ Address varOffset = dest - gen.currAddr();
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+ insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, false);
+
+ return true;
+ */
+
+
+ Address dest = getInterModuleFuncAddr(callee, gen);
+ Register scr = gen.rs()->getScratchRegister(gen);
+ Register lr = gen.rs()->getScratchRegister(gen);
+ //Register scr = gen.rs()->getRegByName("r2");
+ //Register lr = gen.rs()->getRegByName("r3");
+ emitMovePCToReg(scr, gen);
+
+ Address varOffset = dest - gen.currAddr() + 4;
+ //printf("VarOffset = %d\n", varOffset);
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
+
+ // indirect branch
+ instruction branchInsn;
+ branchInsn.clear();
+
+ //Set bits which are 0 for both BR and BLR
+ INSN_SET(branchInsn, 0, 4, 0);
+ INSN_SET(branchInsn, 10, 15, 0);
+
+ //Set register
+ INSN_SET(branchInsn, 5, 9, lr);
+
+ //Set other bits. Basically, these are the opcode bits.
+ //The only difference between BR and BLR is that bit 21 is 1 for BLR.
+ INSN_SET(branchInsn, 16, 31, BRegOp);
+ INSN_SET(branchInsn, 21, 21, 0);
+ insnCodeGen::generate(gen, branchInsn);
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), lr, true);
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, true);
+
+ return true;
+
+ //assert(0); //Not implemented
+ //return emitPLTCommon(callee, false, gen);
}
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.h.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.h 2019-11-06 10:20:08.567523510 -0500
@@ -74,3 +74,3 @@
//TODO Fix for ARM
-#define GPRSAVE_64 (31*GPRSIZE_64)
+#define GPRSAVE_64 (32*GPRSIZE_64)
#define FPRSAVE_64 (32*FPRSIZE_64)
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/registerSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/registerSpace.C 2019-11-06 10:20:08.567523510 -0500
@@ -110,2 +110,4 @@
#elif defined(arch_aarch64)
+ if(number == registerSpace::sp)
+ return REG_SP;
switch (type) {
@@ -342,3 +344,3 @@
- reg->markUsed(true);
+ //reg->markUsed(true);
gen.markRegDefined(reg->number);
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/dynProcess.C.orig
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/dynProcess.C
@@ -3243,25 +3243,13 @@ bool PCProcess::continueSyncRPCThreads() {
}
void PCProcess::addTrap(Address from, Address to, codeGen &gen) {
- map<Address, Breakpoint::ptr>::iterator breakIter =
- installedCtrlBrkpts.find(from);
-
- if( breakIter != installedCtrlBrkpts.end() ) {
- if( !pcProc_->rmBreakpoint(from, breakIter->second) ) {
- // Oops?
- }
- installedCtrlBrkpts.erase(breakIter);
- }
-
- Breakpoint::ptr newBreak = Breakpoint::newTransferBreakpoint(to);
- newBreak->setSuppressCallbacks(true);
-
- if( !pcProc_->addBreakpoint(from, newBreak) ) {
- // Oops?
- }
-
- installedCtrlBrkpts.insert(make_pair(from, newBreak));
- gen.invalidate();
+ gen.invalidate();
+ gen.allocate(4);
+ gen.setAddrSpace(this);
+ gen.setAddr(from);
+ insnCodeGen::generateTrap(gen);
+ trapMapping.addTrapMapping(from, to, true);
+ springboard_cerr << "Generated springboard trap " << hex << from << "->" << to << dec << endl;
}
void PCProcess::removeTrap(Address from) {

View File

@ -1,28 +0,0 @@
--- dyninst-10.1.0/dyninst-10.1.0/instructionAPI/h/Result.h.sv 2018-11-09 11:48:08.000000000 -0500
+++ dyninst-10.1.0/dyninst-10.1.0/instructionAPI/h/Result.h 2018-12-04 22:12:47.369579566 -0500
@@ -449,10 +449,10 @@
snprintf(hex, 20, "%x", val.s32val);
break;
case u64:
- snprintf(hex, 20, "%lx", val.u64val);
+ snprintf(hex, 20, "%" PRIx64, val.u64val);
break;
case s64:
- snprintf(hex, 20, "%lx", val.s64val);
+ snprintf(hex, 20, "%" PRIx64, val.s64val);
break;
case sp_float:
snprintf(hex, 20, "%f", val.floatval);
@@ -464,10 +464,10 @@
snprintf(hex, 20, "%x", val.bitval);
break;
case u48:
- snprintf(hex, 20, "%lx", val.s48val);
+ snprintf(hex, 20, "%" PRIx64, val.s48val);
break;
case s48:
- snprintf(hex, 20, "%lx", val.s48val);
+ snprintf(hex, 20, "%" PRIx64, val.s48val);
break;
case m512:
snprintf(hex, 20, "%p", val.m512val);

View File

@ -1,11 +0,0 @@
--- dyninst-10.1.0/dyninst-10.1.0/cmake/ThreadingBuildingBlocks.cmake.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.1.0/dyninst-10.1.0/cmake/ThreadingBuildingBlocks.cmake 2019-05-30 10:45:15.128872098 -0400
@@ -43,7 +43,7 @@
set(TBB_USE_DEBUG_BUILD OFF CACHE BOOL "Use debug versions of TBB libraries")
# Minimum version of TBB (assumes a dotted-decimal format: YYYY.XX)
-set(_tbb_min_version 2018.6)
+set(_tbb_min_version 2018.0)
set(TBB_MIN_VERSION ${_tbb_min_version} CACHE STRING "Minimum version of TBB (assumes a dotted-decimal format: YYYY.XX)")
if(${TBB_MIN_VERSION} VERSION_LESS ${_tbb_min_version})

View File

@ -0,0 +1,317 @@
Debuginfod is a lightweight web service that indexes ELF/DWARF debugging
resources by build-id and serves them over HTTP.
This patch enables dyninst to query debuginfod servers for a file's
separate debuginfo when it otherwise cannot be found.
This patch also adds a cmake option -DENABLE_DEBUGINFOD to control
whether dyninst is built with debuginfod support.
This requires having the debuginfod client library (libdebuginfod)
and header installed.
Debuginfod is distributed with elfutils, for more information see
https://sourceware.org/elfutils/Debuginfod.html
---
cmake/ElfUtils.cmake | 37 ++++++++---
cmake/Modules/FindLibDebuginfod.cmake | 76 +++++++++++++++++++++
cmake/options.cmake | 2 +
elf/CMakeLists.txt | 3 +
elf/src/Elf_X.C | 95 ++++++++++++++++++++-------
5 files changed, 178 insertions(+), 35 deletions(-)
create mode 100644 cmake/Modules/FindLibDebuginfod.cmake
--- dyninst-10.2.1/dyninst-10.2.1/cmake/ElfUtils.cmake
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/ElfUtils.cmake
@@ -28,7 +28,7 @@
#
#======================================================================================
-if(LibElf_FOUND AND LibDwarf_FOUND)
+if(LibElf_FOUND AND LibDwarf_FOUND AND (LibDebuginfod_FOUND OR NOT ENABLE_DEBUGINFOD))
return()
endif()
@@ -37,7 +37,12 @@ if(NOT UNIX)
endif()
# Minimum acceptable version of elfutils
-set(_min_version 0.178)
+if(ENABLE_DEBUGINFOD)
+ set(_min_version 0.179)
+else()
+ set(_min_version 0.178)
+endif()
+
set(ElfUtils_MIN_VERSION ${_min_version}
CACHE STRING "Minimum acceptable elfutils version")
if(${ElfUtils_MIN_VERSION} VERSION_LESS ${_min_version})
@@ -62,7 +67,7 @@ set(ElfUtils_LIBRARYDIR "${ElfUtils_ROOT_DIR}/lib"
CACHE PATH "Hint directory that contains the elfutils library files")
# libelf/dwarf-specific directory hints
-foreach(l LibElf LibDwarf)
+foreach(l LibElf LibDwarf LibDebuginfod)
foreach(d ROOT_DIR INCLUDEDIR LIBRARYDIR)
set(${l}_${d} ${ElfUtils_${d}})
endforeach()
@@ -72,18 +77,30 @@ endforeach()
find_package(LibElf ${ElfUtils_MIN_VERSION})
-# Don't search for libdw if we didn't find a suitable libelf
+# Don't search for libdw or libdebuginfod if we didn't find a suitable libelf
if(LibElf_FOUND)
find_package(LibDwarf ${ElfUtils_MIN_VERSION})
+ if (ENABLE_DEBUGINFOD)
+ find_package(LibDebuginfod ${ElfUtils_MIN_VERSION})
+ endif()
endif()
# -------------- SOURCE BUILD -------------------------------------------------
-if(LibElf_FOUND AND LibDwarf_FOUND)
- set(_eu_root ${ElfUtils_ROOT_DIR})
- set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS})
- set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS})
- set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES})
+if(LibElf_FOUND AND LibDwarf_FOUND AND (NOT ENABLE_DEBUGINFOD OR LibDebuginfod_FOUND))
+ if(ENABLE_DEBUGINFOD AND LibDebuginfod_FOUND)
+ set(_eu_root ${ElfUtils_ROOT_DIR})
+ set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS} ${LibDebuginfod_INCLUDE_DIRS})
+ set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS} ${LibDebuginfod_LIBRARY_DIRS})
+ set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES} ${LibDebuginfod_LIBRARIES})
+ else()
+ set(_eu_root ${ElfUtils_ROOT_DIR})
+ set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS})
+ set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS})
+ set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES})
+ endif()
add_library(ElfUtils SHARED IMPORTED)
+elseif(ENABLE_DEBUGINFOD AND NOT LibDebuginfod_FOUND)
+ message(FATAL_ERROR "Debuginfod enabled but not found")
elseif(NOT (LibElf_FOUND AND LibDwarf_FOUND) AND STERILE_BUILD)
message(FATAL_ERROR "Elfutils not found and cannot be downloaded because build is sterile.")
else()
--- /dev/null
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/Modules/FindLibDebuginfod.cmake
@@ -0,0 +1,76 @@
+#========================================================================================
+# FindDebuginfod
+# -----------
+#
+# Find debuginfod library and headers
+#
+# The module defines the following variables:
+#
+# This module reads hints about search locations from variables::
+#
+# LibDebuginfod_ROOT_DIR - Base directory the of libdebuginfod installation
+# LibDebuginfod_INCLUDEDIR - Hint directory that contains the libdebuginfod headers files
+# LibDebuginfod_LIBRARYDIR - Hint directory that contains the libdebuginfod library files
+#
+# and saves search results persistently in CMake cache entries::
+#
+# LibDebuginfod_FOUND - True if headers and requested libraries were found
+# LibDebuginfod_INCLUDE_DIRS - libdebuginfod include directories
+# LibDebuginfod_LIBRARY_DIRS - Link directories for libdebuginfod libraries
+# LibDebuginfod_LIBRARIES - libdebuginfod library files
+#
+# Utilize package config (e.g. /usr/lib64/pkgconfig/libdebuginfod.pc) to fetch
+# version information.
+#
+#========================================================================================
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_Debuginfod QUIET REQUIRED libdebuginfod>=${ElfUtils_MIN_VERSION})
+set(LibDebuginfod_VERSION "${PC_Debuginfod_VERSION}")
+
+find_path(LibDebuginfod_INCLUDE_DIRS
+ NAMES
+ debuginfod.h
+ HINTS
+ ${PC_Debuginfod_INCLUDEDIR}
+ ${PC_Debuginfod_INCLUDE_DIRS}
+ ${LibDebuginfod_ROOT_DIR}/include
+ ${LibDebuginfod_ROOT_DIR}
+ ${LibDebuginfod_INCLUDEDIR}
+ PATHS
+ ${DYNINST_SYSTEM_INCLUDE_PATHS}
+ PATH_SUFFIXES
+ ${_path_suffixes}
+ DOC
+ "libdebuginfod include directories")
+
+find_library(LibDebuginfod_LIBRARIES
+ NAMES
+ libdebuginfod.so.1 libdebuginfod.so
+ HINTS
+ ${PC_Debuginfod_LIBDIR}
+ ${PC_Debuginfod_LIBRARY_DIRS}
+ ${LibDebuginfod_ROOT_DIR}/lib
+ ${LibDebuginfod_ROOT_DIR}
+ ${LibDebuginfod_LIBRARYDIR}
+ PATHS
+ ${DYNINST_SYSTEM_LIBRARY_PATHS}
+ PATH_SUFFIXES
+ ${_path_suffixes})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibDebuginfod
+ FOUND_VAR
+ LibDebuginfod_FOUND
+ REQUIRED_VARS
+ LibDebuginfod_INCLUDE_DIRS
+ LibDebuginfod_LIBRARIES
+ VERSION_VAR
+ LibDebuginfod_VERSION)
+
+if(LibDebuginfod_FOUND)
+ set(LibDebuginfod_INCLUDE_DIRS ${LibDebuginfod_INCLUDE_DIRS})
+ set(LibDebuginfod_LIBRARIES ${LibDebuginfod_LIBRARIES})
+ get_filename_component(_debuginfod_dir ${LibDebuginfod_LIBRARIES} DIRECTORY)
+ set(LibDebuginfod_LIBRARY_DIRS ${_debuginfod_dir} "${_debuginfod_dir}/elfutils")
+endif()
--- dyninst-10.2.1/dyninst-10.2.1/cmake/options.cmake
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/options.cmake
@@ -16,6 +16,8 @@ option(USE_COTIRE "Enable Cotire precompiled headers")
option (ENABLE_LTO "Enable Link-Time Optimization" OFF)
+option(ENABLE_DEBUGINFOD "Enable debuginfod support" OFF)
+
# Some global on/off switches
if (LIGHTWEIGHT_SYMTAB)
add_definitions (-DWITHOUT_SYMTAB_API -DWITH_SYMLITE)
--- dyninst-10.2.1/dyninst-10.2.1/elf/CMakeLists.txt
+++ dyninst-10.2.1/dyninst-10.2.1/elf/CMakeLists.txt
@@ -27,5 +27,8 @@ endif()
add_dependencies(dynElf ElfUtils)
target_link_private_libraries(dynElf ${ElfUtils_LIBRARIES})
+if (ENABLE_DEBUGINFOD AND LibDebuginfod_FOUND)
+ add_definitions(-DDEBUGINFOD_LIB)
+endif()
add_definitions(-DDYNELF_LIB)
--- dyninst-10.2.1/dyninst-10.2.1/elf/src/Elf_X.C
+++ dyninst-10.2.1/dyninst-10.2.1/elf/src/Elf_X.C
@@ -47,6 +47,9 @@
#include <sstream>
#include <libelf.h>
+#if DEBUGINFOD_LIB
+#include <elfutils/debuginfod.h>
+#endif
using namespace std;
using boost::crc_32_type;
@@ -1722,37 +1725,79 @@ bool Elf_X::findDebugFile(std::string origfilename, string &output_name, char* &
}
}
- if (debugFileFromDebugLink.empty())
- return false;
+ if (!debugFileFromDebugLink.empty()) {
+ char *mfPathNameCopy = strdup(origfilename.c_str());
+ string objectFileDirName = dirname(mfPathNameCopy);
- char *mfPathNameCopy = strdup(origfilename.c_str());
- string objectFileDirName = dirname(mfPathNameCopy);
+ vector<string> fnames = list_of
+ (objectFileDirName + "/" + debugFileFromDebugLink)
+ (objectFileDirName + "/.debug/" + debugFileFromDebugLink)
+ ("/usr/lib/debug/" + objectFileDirName + "/" + debugFileFromDebugLink);
- vector<string> fnames = list_of
- (objectFileDirName + "/" + debugFileFromDebugLink)
- (objectFileDirName + "/.debug/" + debugFileFromDebugLink)
- ("/usr/lib/debug/" + objectFileDirName + "/" + debugFileFromDebugLink);
+ free(mfPathNameCopy);
- free(mfPathNameCopy);
+ for(unsigned i = 0; i < fnames.size(); i++) {
+ bool result = loadDebugFileFromDisk(fnames[i], output_buffer, output_buffer_size);
+ if (!result)
+ continue;
- for(unsigned i = 0; i < fnames.size(); i++) {
- bool result = loadDebugFileFromDisk(fnames[i], output_buffer, output_buffer_size);
- if (!result)
- continue;
-
- boost::crc_32_type crcComputer;
- crcComputer.process_bytes(output_buffer, output_buffer_size);
- if(crcComputer.checksum() != debugFileCrc) {
- munmap(output_buffer, output_buffer_size);
- continue;
- }
+ boost::crc_32_type crcComputer;
+ crcComputer.process_bytes(output_buffer, output_buffer_size);
+ if(crcComputer.checksum() != debugFileCrc) {
+ munmap(output_buffer, output_buffer_size);
+ continue;
+ }
+
+ output_name = fnames[i];
+ cached_debug_buffer = output_buffer;
+ cached_debug_size = output_buffer_size;
+ cached_debug_name = output_name;
+ return true;
+ }
+ }
- output_name = fnames[i];
- cached_debug_buffer = output_buffer;
- cached_debug_size = output_buffer_size;
- cached_debug_name = output_name;
- return true;
+#ifdef DEBUGINFOD_LIB
+ if (!debugFileFromBuildID.empty()) {
+ // Given /usr/lib/debug/.buildid/XX/YYYYYY.debug, isolate XXYYYYYY.
+ size_t idx1 = debugFileFromBuildID.find_last_of("/");
+ size_t idx2 = debugFileFromBuildID.find_last_of(".");
+
+ if (idx1 == string::npos || idx2 == string::npos
+ || idx1 < 2 || idx1 > idx2)
+ return false;
+
+ idx1 -= 2;
+ string buildid(debugFileFromBuildID.substr(idx1, idx2 - idx1));
+ buildid.erase(2, 1);
+
+ debuginfod_client *client = debuginfod_begin();
+ if (client == NULL)
+ return false;
+
+ char *filename;
+ int fd = debuginfod_find_debuginfo(client,
+ (const unsigned char *)buildid.c_str(),
+ 0, &filename);
+ debuginfod_end(client);
+
+ if (fd >= 0) {
+ string fname = string(filename);
+ free(filename);
+ close(fd);
+
+ bool result = loadDebugFileFromDisk(fname,
+ output_buffer,
+ output_buffer_size);
+ if (result) {
+ output_name = fname;
+ cached_debug_buffer = output_buffer;
+ cached_debug_size = output_buffer_size;
+ cached_debug_name = output_name;
+ return true;
+ }
+ }
}
+#endif
return false;
}

View File

@ -0,0 +1,11 @@
--- dyninst-10.2.1/dyninst-10.2.1/cmake/ThreadingBuildingBlocks.cmake.orig 2019-05-16 14:40:05.000000000 -0400
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/ThreadingBuildingBlocks.cmake 2019-05-30 10:45:15.128872098 -0400
@@ -50,7 +50,7 @@
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(_tbb_min_version 2019.7)
else()
- set(_tbb_min_version 2018.6)
+ set(_tbb_min_version 2018.0)
endif()
set(TBB_MIN_VERSION ${_tbb_min_version} CACHE STRING "Minimum version of TBB (assumes a dotted-decimal format: YYYY.XX)")

View File

@ -0,0 +1,13 @@
diff --git a/testsuite-10.1.0/src/dyninst/test1_3.C b/testsuite-10.1.0/src/dyninst/test1_3.C
index d32f630..b9bd0ba 100644
--- a/testsuite-10.1.0/src/dyninst/test1_3.C
+++ b/testsuite-10.1.0/src/dyninst/test1_3.C
@@ -134,7 +134,7 @@ test_results_t test1_3_Mutator::executeTest()
}
// see if we can find the address
- if (expr3_1->getBaseAddr() <= 0)
+ if (expr3_1->getBaseAddr() == 0)
{
logerror("*Error*: address %p for %s is not valid\n",
expr3_1->getBaseAddr(), globalVar);

View File

@ -1,5 +1,20 @@
--- dyninst-10.1.0/testsuite-10.1.0/src/instruction/test_instruction_farcall.C
+++ dyninst-10.1.0/testsuite-10.1.0/src/instruction/test_instruction_farcall.C
--- dyninst-10.2.0/testsuite-10.1.0/CMakeLists.txt
+++ dyninst-10.2.0/testsuite-10.1.0/CMakeLists.txt
@@ -111,7 +111,8 @@
if(UNIX)
enable_language(ASM-ATT)
- if("${DYNINST_PLATFORM}" MATCHES "i386")
- enable_language(ASM_NASM)
- endif()
+# nasm/yasm are deprecated
+# if("${DYNINST_PLATFORM}" MATCHES "i386")
+# enable_language(ASM_NASM)
+# endif()
elseif(WIN32)
enable_language(ASM_MASM)
--- dyninst-10.2.0/testsuite-10.1.0/src/instruction/test_instruction_farcall.C
+++ dyninst-10.2.0/testsuite-10.1.0/src/instruction/test_instruction_farcall.C
@@ -96,21 +96,21 @@ test_results_t test_instruction_farcall_Mutator::executeTest()
if(decodedInsns.size() != expectedInsns) // six valid, one invalid
{

View File

@ -0,0 +1,15 @@
--- dyninst-10.1.0/testsuite-10.1.0/src/proccontrol/pcontrol_mutatee_tools.c.orig 2019-05-31 05:20:00.492379706 +0200
+++ dyninst-10.1.0/testsuite-10.1.0/src/proccontrol/pcontrol_mutatee_tools.c 2019-05-31 05:10:11.354826668 +0200
@@ -62,9 +62,9 @@
#if !defined(os_windows_test)
#include <poll.h>
-static unsigned int gettid(){
- return (unsigned int)pthread_self();
-}
+// static unsigned int gettid(){
+// return (unsigned int)pthread_self();
+// }
#endif
thread_t threads[MAX_POSSIBLE_THREADS];

View File

@ -0,0 +1,14 @@
--- dyninst-10.2.0/testsuite-10.1.0/src/test_lib.h
+++ dyninst-10.2.0/testsuite-10.1.0/src/test_lib.h
@@ -158,3 +158,3 @@
- TESTLIB_DLL_EXPORT virtual ~LocErr() THROW;
+ TESTLIB_DLL_EXPORT virtual ~LocErr() throw();
--- dyninst-10.2.0/testsuite-10.1.0/src/test_lib.C
+++ dyninst-10.2.0/testsuite-10.1.0/src/test_lib.C
@@ -112,3 +112,3 @@
-LocErr::~LocErr() THROW
+LocErr::~LocErr() throw()
{}

View File

@ -2,25 +2,29 @@ Summary: An API for Run-time Code Generation
License: LGPLv2+
Name: dyninst
Group: Development/Libraries
Release: 4%{?dist}
Release: 2%{?dist}
URL: http://www.dyninst.org
Version: 10.1.0
Version: 10.2.1
ExclusiveArch: %{ix86} x86_64 ppc64le aarch64
%define __testsuite_version 10.1.0
Source0: https://github.com/dyninst/dyninst/archive/v%{version}/dyninst-%{version}.tar.gz
Source1: https://github.com/dyninst/testsuite/archive/v%{version}/testsuite-%{version}.tar.gz
Source1: https://github.com/dyninst/testsuite/archive/v10.1.0/testsuite-%{__testsuite_version}.tar.gz
Patch1: dyninst-10.1.0-tbb.patch
Patch2: dyninst-10.1.0-result.patch
Patch3: testsuite-10.1.0-386.patch
Patch4: dyninst-10.1.0-aarch-regs.patch
Patch1: %{name}-gcc11.patch
Patch2: %{name}-10.2.1-dbid.patch
Patch3: testsuite-10.1.0-gettid.patch
Patch4: testsuite-10.1.0-386.patch
Patch5: testsuite-10.1.0-throw.patch
Patch6: %{name}-10.2.1-tbb.patch
%global dyninst_base dyninst-%{version}
%global testsuite_base testsuite-%{version}
%global testsuite_base testsuite-%{__testsuite_version}
BuildRequires: gcc-c++
BuildRequires: elfutils-devel
BuildRequires: elfutils-libelf-devel
BuildRequires: elfutils-debuginfod-client-devel
BuildRequires: boost-devel
BuildRequires: binutils-devel
BuildRequires: cmake
@ -28,7 +32,7 @@ BuildRequires: libtirpc-devel
BuildRequires: tbb tbb-devel
# Extra requires just for the testsuite
BuildRequires: gcc-gfortran glibc-static libstdc++-static nasm libxml2-devel
BuildRequires: gcc-gfortran glibc-static libstdc++-static libxml2-devel
# Testsuite files should not provide/require anything
%{?filter_setup:
@ -87,10 +91,12 @@ making sure that dyninst works properly.
%setup -q -n %{name}-%{version} -c
%setup -q -T -D -a 1
%patch1 -p1 -b.tbb
%patch2 -p1 -b.result
%patch3 -p1 -b.386
%patch4 -p1 -b.aarch
%patch1 -p1 -b .gcc11
%patch2 -p1 -b .dbid
%patch3 -p1 -b .gettid
%patch4 -p1 -b .386
%patch5 -p1 -b .throw
%patch6 -p1 -b .tbb
# cotire seems to cause non-deterministic gcc errors
# https://bugzilla.redhat.com/show_bug.cgi?id=1420551
@ -101,8 +107,18 @@ sed -i.cotire -e 's/USE_COTIRE true/USE_COTIRE false/' \
cd %{dyninst_base}
CFLAGS="$CFLAGS $RPM_OPT_FLAGS"
LDFLAGS="$LDFLAGS $RPM_LD_FLAGS"
%ifarch %{ix86}
CFLAGS="$CFLAGS -fno-lto -march=i686"
LDFLAGS="$LDFLAGS -fno-lto"
%endif
CXXFLAGS="$CFLAGS"
export CFLAGS CXXFLAGS LDFLAGS
%cmake \
-DENABLE_STATIC_LIBS=1 \
-DENABLE_DEBUGINFOD=1 \
-DINSTALL_LIB_DIR:PATH=%{_libdir}/dyninst \
-DINSTALL_INCLUDE_DIR:PATH=%{_includedir}/dyninst \
-DINSTALL_CMAKE_DIR:PATH=%{_libdir}/cmake/Dyninst \
@ -142,6 +158,13 @@ cd ../%{testsuite_base}
mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/dyninst" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf
# Ugly hack to mask testsuite files from debuginfo extraction. Running the
# testsuite requires debuginfo, so extraction is useless. However, debuginfo
# extraction is still nice for the main libraries, so we don't want to disable
# it package-wide. The permissions are restored by attr(755,-,-) in files.
find %{buildroot}%{_libdir}/dyninst/testsuite/ \
-type f '!' -name '*.a' -execdir chmod 644 '{}' '+'
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
@ -177,17 +200,17 @@ echo "%{_libdir}/dyninst" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf
%files testsuite
%{_bindir}/parseThat
%exclude %{_bindir}/cfg_to_dot
%exclude /usr/bin/codeCoverage
%exclude /usr/bin/unstrip
%exclude /usr/bin/ddb.db
%exclude /usr/bin/params.db
%exclude /usr/bin/unistd.db
%dir %{_libdir}/dyninst/testsuite/
%attr(755,root,root) %{_libdir}/dyninst/testsuite/*[!a]
%attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a
%changelog
* Fri Nov 06 2020 Stan Cox <scox@redhat.com> - 10.2.1-2
- Enable debuginfod
* Wed Oct 28 2020 Stan Cox <scox@redhat.com> - 10.2.1-1
- Update to 10.2.1
* Tue Nov 19 2019 Stan Cox <scox@redhat.com> - 10.1.0-4
- Resolves: rhbz#963475 dyninst must be ported to aarch64
Remove Requires: glibc-static from %package testsuite