From 07af1b4b2a5f4f174aa08e1ea655e145e32ae121 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 29 Oct 2020 17:34:54 -0400 Subject: [PATCH] Update to 10.2.1 --- .gitignore | 1 + dyninst-10.1.0-aarch-regs.patch | 309 ----------------- dyninst-10.1.0-result.patch | 28 -- dyninst-10.2.1-dbid.patch | 326 ++++++++++++++++++ ....2.0-pie.patch => dyninst-10.2.1-pie.patch | 4 +- dyninst.spec | 25 +- sources | 2 +- testsuite-10.1.0-386.patch | 8 +- testsuite-10.1.0-throw.patch | 14 + 9 files changed, 363 insertions(+), 354 deletions(-) delete mode 100644 dyninst-10.1.0-aarch-regs.patch delete mode 100644 dyninst-10.1.0-result.patch create mode 100644 dyninst-10.2.1-dbid.patch rename dyninst-10.2.0-pie.patch => dyninst-10.2.1-pie.patch (72%) create mode 100644 testsuite-10.1.0-throw.patch diff --git a/.gitignore b/.gitignore index b84defc..3fd4028 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ /testsuite-10.1.0.tar.gz /dyninst-10.1.0.tar.gz /dyninst-10.2.0.tar.gz +/dyninst-10.2.1.tar.gz diff --git a/dyninst-10.1.0-aarch-regs.patch b/dyninst-10.1.0-aarch-regs.patch deleted file mode 100644 index 814137c..0000000 --- a/dyninst-10.1.0-aarch-regs.patch +++ /dev/null @@ -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 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::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) { diff --git a/dyninst-10.1.0-result.patch b/dyninst-10.1.0-result.patch deleted file mode 100644 index 2738cf2..0000000 --- a/dyninst-10.1.0-result.patch +++ /dev/null @@ -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); diff --git a/dyninst-10.2.1-dbid.patch b/dyninst-10.2.1-dbid.patch new file mode 100644 index 0000000..91b5407 --- /dev/null +++ b/dyninst-10.2.1-dbid.patch @@ -0,0 +1,326 @@ +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() +@@ -104,7 +121,7 @@ else() + if(NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR NOT (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")) + message(FATAL_ERROR "ElfUtils will only build with the GNU compiler") + endif() +- ++ + include(ExternalProject) + externalproject_add( + ElfUtils + +--- /dedyninst-10.2.1/dyninst-10.2.1/null ++++ b/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 + #include + ++#if DEBUGINFOD_LIB ++#include ++#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 fnames = list_of ++ (objectFileDirName + "/" + debugFileFromDebugLink) ++ (objectFileDirName + "/.debug/" + debugFileFromDebugLink) ++ ("/usr/lib/debug/" + objectFileDirName + "/" + debugFileFromDebugLink); + +- vector 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; + } diff --git a/dyninst-10.2.0-pie.patch b/dyninst-10.2.1-pie.patch similarity index 72% rename from dyninst-10.2.0-pie.patch rename to dyninst-10.2.1-pie.patch index 32262c1..095f037 100644 --- a/dyninst-10.2.0-pie.patch +++ b/dyninst-10.2.1-pie.patch @@ -1,5 +1,5 @@ ---- dyninst-10.2.0/dyninst-10.2.0/dyninstAPI_RT/CMakeLists.txt 2020-02-24 09:41:30.207108160 -0500 -+++ dyninst-10.2.0/dyninst-10.2.0/dyninstAPI_RT/CMakeLists.txt 2020-08-25 15:57:28.437496257 -0400 +--- dyninst-10.2.1/dyninst-10.2.1/dyninstAPI_RT/CMakeLists.txt 2020-02-24 09:41:30.207108160 -0500 ++++ dyninst-10.2.1/dyninst-10.2.1/dyninstAPI_RT/CMakeLists.txt 2020-08-25 15:57:28.437496257 -0400 @@ -5,4 +5,4 @@ set (DYNINST_ROOT ${PROJECT_SOURCE_DIR}/..) -set(CMAKE_C_FLAGS "${DYNINST_RT_CMAKE_C_FLAGS}") diff --git a/dyninst.spec b/dyninst.spec index bccc268..7f428c3 100644 --- a/dyninst.spec +++ b/dyninst.spec @@ -1,19 +1,20 @@ Summary: An API for Run-time Code Generation License: LGPLv2+ Name: dyninst -Release: 2%{?dist} +Release: 1%{?dist} URL: http://www.dyninst.org -Version: 10.2.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/v10.1.0/testsuite-%{__testsuite_version}.tar.gz -Patch1: dyninst-10.2.0-pie.patch -Patch2: testsuite-10.1.0-gettid.patch -Patch3: testsuite-10.1.0-386.patch -Patch4: %{name}-gcc11.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 %global dyninst_base dyninst-%{version} %global testsuite_base testsuite-%{__testsuite_version} @@ -76,10 +77,11 @@ making sure that dyninst works properly. %setup -q -n %{name}-%{version} -c %setup -q -T -D -a 1 -%patch1 -p1 -b.pie -%patch2 -p1 -b.gettid -%patch3 -p1 -b.386 -%patch4 -p1 -b .gcc11 +%patch1 -p1 -b .gcc11 +%patch2 -p1 -b .dbid +%patch3 -p1 -b .gettid +%patch4 -p1 -b .386 +%patch5 -p1 -b .throw # cotire seems to cause non-deterministic gcc errors # https://bugzilla.redhat.com/show_bug.cgi?id=1420551 @@ -175,6 +177,9 @@ echo "%{_libdir}/dyninst" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf %attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a %changelog +* Wed Oct 28 2020 Stan Cox - 10.2.1-1 +- Update to 10.2.1 + * Tue Oct 27 2020 Jeff Law - 10.2.0-2 - Fix C++17 issue caught by gcc-11 diff --git a/sources b/sources index 496c76e..3758b48 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ +SHA512 (dyninst-10.2.1.tar.gz) = 5666ffd888afdb9493bd495aa6027ca5b9f71fe811a6d88777d55b612c92f73dc6c008c1738be111175a31fb0a2ec804d8ffc3e79888d8366ae5b5b624537055 SHA512 (testsuite-10.1.0.tar.gz) = 47b91ebc0623f672378086a5f8d84e3934bd6b22d8932b12aaad257ccf7eb109505edb63dfbc3eb15aa099fc488a517835412099a77e3e0dd1275b3e3f672b3b -SHA512 (dyninst-10.2.0.tar.gz) = 32ddf871a8b486bb38530a264b140f504bfd5fb9401c940c6e36540f932ad8dd87375a517324416035ba6eeb05107cf03acebc88bdaad4b5d4c3643afaa5ac5c diff --git a/testsuite-10.1.0-386.patch b/testsuite-10.1.0-386.patch index eb46c9f..7fbee48 100644 --- a/testsuite-10.1.0-386.patch +++ b/testsuite-10.1.0-386.patch @@ -1,5 +1,5 @@ ---- dyninst-10.1.0/testsuite-10.1.0/CMakeLists.txt -+++ dyninst-10.1.0/testsuite-10.1.0/CMakeLists.txt +--- 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) @@ -13,8 +13,8 @@ elseif(WIN32) enable_language(ASM_MASM) ---- 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/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 { diff --git a/testsuite-10.1.0-throw.patch b/testsuite-10.1.0-throw.patch new file mode 100644 index 0000000..886e9b5 --- /dev/null +++ b/testsuite-10.1.0-throw.patch @@ -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() + {}