[dsymutil] Add --linker parallel to more tests. (#78581)

This patch adds check for parallel linker to tests located in the root
of test/tools/dsymutil.
This commit is contained in:
Alexey Lapshin
2024-01-23 13:00:49 +03:00
committed by GitHub
parent 376f3be834
commit 0ed8194256
17 changed files with 83 additions and 37 deletions

View File

@@ -38,22 +38,22 @@ public:
/// Checks that the specified DWARF expression operand \p Op references live
/// code section and returns the relocation adjustment value (to get the
/// linked address this value might be added to the source expression operand
/// address).
/// address). Print debug output if \p Verbose is true.
/// \returns relocation adjustment value or std::nullopt if there is no
/// corresponding live address.
virtual std::optional<int64_t>
getExprOpAddressRelocAdjustment(DWARFUnit &U,
const DWARFExpression::Operation &Op,
uint64_t StartOffset, uint64_t EndOffset) = 0;
virtual std::optional<int64_t> getExprOpAddressRelocAdjustment(
DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset,
uint64_t EndOffset, bool Verbose) = 0;
/// Checks that the specified subprogram \p DIE references the live code
/// section and returns the relocation adjustment value (to get the linked
/// address this value might be added to the source subprogram address).
/// Allowed kinds of input DIE: DW_TAG_subprogram, DW_TAG_label.
/// Print debug output if \p Verbose is true.
/// \returns relocation adjustment value or std::nullopt if there is no
/// corresponding live address.
virtual std::optional<int64_t>
getSubprogramRelocAdjustment(const DWARFDie &DIE) = 0;
getSubprogramRelocAdjustment(const DWARFDie &DIE, bool Verbose) = 0;
// Returns the library install name associated to the AddessesMap.
virtual std::optional<StringRef> getLibraryInstallName() = 0;
@@ -90,7 +90,7 @@ public:
/// second is the relocation adjustment value if the live address is
/// referenced.
std::pair<bool, std::optional<int64_t>>
getVariableRelocAdjustment(const DWARFDie &DIE) {
getVariableRelocAdjustment(const DWARFDie &DIE, bool Verbose) {
assert((DIE.getTag() == dwarf::DW_TAG_variable ||
DIE.getTag() == dwarf::DW_TAG_constant) &&
"Wrong type of input die");
@@ -149,9 +149,9 @@ public:
HasLocationAddress = true;
// Check relocation for the address.
if (std::optional<int64_t> RelocAdjustment =
getExprOpAddressRelocAdjustment(*U, Op,
AttrOffset + CurExprOffset,
AttrOffset + Op.getEndOffset()))
getExprOpAddressRelocAdjustment(
*U, Op, AttrOffset + CurExprOffset,
AttrOffset + Op.getEndOffset(), Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
} break;
case dwarf::DW_OP_constx:
@@ -164,8 +164,8 @@ public:
if (std::optional<int64_t> RelocAdjustment =
getExprOpAddressRelocAdjustment(
*U, Op, *AddressOffset,
*AddressOffset +
DIE.getDwarfUnit()->getAddressByteSize()))
*AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(),
Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
}
} break;

View File

@@ -465,7 +465,7 @@ DWARFLinker::getVariableRelocAdjustment(AddressesMap &RelocMgr,
if (std::optional<int64_t> RelocAdjustment =
RelocMgr.getExprOpAddressRelocAdjustment(
*U, Op, AttrOffset + CurExprOffset,
AttrOffset + Op.getEndOffset()))
AttrOffset + Op.getEndOffset(), Options.Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
} break;
case dwarf::DW_OP_constx:
@@ -478,7 +478,8 @@ DWARFLinker::getVariableRelocAdjustment(AddressesMap &RelocMgr,
if (std::optional<int64_t> RelocAdjustment =
RelocMgr.getExprOpAddressRelocAdjustment(
*U, Op, *AddressOffset,
*AddressOffset + DIE.getDwarfUnit()->getAddressByteSize()))
*AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(),
Options.Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
}
} break;
@@ -552,7 +553,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE(
assert(LowPc && "low_pc attribute is not an address.");
std::optional<int64_t> RelocAdjustment =
RelocMgr.getSubprogramRelocAdjustment(DIE);
RelocMgr.getSubprogramRelocAdjustment(DIE, Options.Verbose);
if (!RelocAdjustment)
return Flags;

View File

@@ -1372,7 +1372,7 @@ DIE *CompileUnit::createPlainDIEandCloneAttributes(
// Get relocation adjustment value for the current function.
FuncAddressAdjustment =
getContaingFile().Addresses->getSubprogramRelocAdjustment(
getDIE(InputDieEntry));
getDIE(InputDieEntry), false);
} else if (InputDieEntry->getTag() == dwarf::DW_TAG_label) {
// Get relocation adjustment value for the current label.
std::optional<uint64_t> lowPC =
@@ -1386,7 +1386,7 @@ DIE *CompileUnit::createPlainDIEandCloneAttributes(
// Get relocation adjustment value for the current variable.
std::pair<bool, std::optional<int64_t>> LocExprAddrAndRelocAdjustment =
getContaingFile().Addresses->getVariableRelocAdjustment(
getDIE(InputDieEntry));
getDIE(InputDieEntry), false);
HasLocationExpressionAddress = LocExprAddrAndRelocAdjustment.first;
if (LocExprAddrAndRelocAdjustment.first &&

View File

@@ -115,7 +115,8 @@ Error DWARFLinkerImpl::link() {
}
if (GlobalData.getOptions().Verbose) {
outs() << "OBJECT: " << Context->InputDWARFFile.FileName << "\n";
outs() << "DEBUG MAP OBJECT: " << Context->InputDWARFFile.FileName
<< "\n";
for (const std::unique_ptr<DWARFUnit> &OrigCU :
Context->InputDWARFFile.Dwarf->compile_units()) {

View File

@@ -741,7 +741,7 @@ bool DependencyTracker::isLiveVariableEntry(const UnitEntryPairTy &Entry,
// enclosing function, unless requested explicitly.
std::pair<bool, std::optional<int64_t>> LocExprAddrAndRelocAdjustment =
Entry.CU->getContaingFile().Addresses->getVariableRelocAdjustment(
DIE);
DIE, Entry.CU->getGlobalData().getOptions().Verbose);
if (LocExprAddrAndRelocAdjustment.first)
Info.setHasAnAddress();
@@ -784,7 +784,7 @@ bool DependencyTracker::isLiveSubprogramEntry(const UnitEntryPairTy &Entry) {
RelocAdjustment =
Entry.CU->getContaingFile().Addresses->getSubprogramRelocAdjustment(
DIE);
DIE, Entry.CU->getGlobalData().getOptions().Verbose);
if (!RelocAdjustment)
return false;

View File

@@ -1,5 +1,7 @@
RUN: dsymutil -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s
RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s
The tested object file has been created by the dummy Objective-C code:
@interface Foo
@end

View File

@@ -11,6 +11,17 @@ RUN: dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib
RUN: not dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm42 2>&1 | FileCheck %s -check-prefix=BADARCH
RUN: not dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch i386 2>&1 | FileCheck %s -check-prefix=EMPTY
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch all | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch='*' | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 | FileCheck %s -check-prefixes=ARM64,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm | FileCheck %s -check-prefixes=ARMV7S,ARMV7,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch armv7 | FileCheck %s -check-prefixes=ARMV7,CHECK
RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 -arch armv7s | FileCheck %s -check-prefixes=ARM64,ARMV7S,CHECK
RUN: not dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm42 2>&1 | FileCheck %s -check-prefix=BADARCH
RUN: not dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch i386 2>&1 | FileCheck %s -check-prefix=EMPTY
ARMV7: ---
ARMV7-NOT: ...

View File

@@ -1,5 +1,7 @@
# RUN: dsymutil -no-output -oso-prepend-path=%p -y %s 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
# RUN: dsymutil --linker parallel -no-output -oso-prepend-path=%p -y %s 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
# This is the archive member part of basic-archive.macho.x86_64 debug map with corrupted timestamps.
# CHECK: warning: {{.*}}libbasic.a(basic2.macho.x86_64.o): [[MSG]]

View File

@@ -6,6 +6,11 @@ RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -D %p/Inputs %p/Inputs/ba
RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -D %p/Inputs %p/Inputs/two-level-relink.macho.arm64.dylib | FileCheck %s --check-prefix=CHECK-RELINK-TWO
RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -build-variant-suffix=_debug -D WrongPath -D %p/Inputs %p/Inputs/variant-relink.macho.arm64.dylib | FileCheck %s --check-prefix=CHECK-RELINK-VARIANT
RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE
RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 %p/Inputs/basic-lto.macho.x86_64 %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefixes=CHECK,CHECK-LTO,CHECK-ARCHIVE
This test check the basic Dwarf linking process through the debug dumps.
================================= Simple link ================================

View File

@@ -4,6 +4,13 @@ RUN: dsymutil -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-arch
RUN: dsymutil -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NOT-FOUND
RUN: not dsymutil -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO-EXECUTABLE
RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
RUN: dsymutil --linker parallel -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-ARCHIVE
RUN: dsymutil --linker parallel -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NOT-FOUND
RUN: not dsymutil --linker parallel -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO-EXECUTABLE
Check that We can parse the debug map of the basic executable.

View File

@@ -1,6 +1,9 @@
RUN: dsymutil -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=ALL,I386 %s
RUN: dsymutil -arch i386 -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=I386,ONE %s
RUN: dsymutil --linker parallel -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=ALL,I386 %s
RUN: dsymutil --linker parallel -arch i386 -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=I386,ONE %s
ALL: ----------------------------------------------------------------------
ALL-NEXT: Symbol table for: '{{.*}}fat-test.dylib' (x86_64)

View File

@@ -1,5 +1,7 @@
RUN: dsymutil -f -verbose -no-output %p/Inputs/fat-test.dylib -oso-prepend-path %p | FileCheck %s
RUN: dsymutil --linker parallel -f -verbose -no-output %p/Inputs/fat-test.dylib -oso-prepend-path %p | FileCheck %s
This test doesn't produce any filesytstem output, we just look at the verbose
log output.

View File

@@ -3,8 +3,14 @@ REQUIRES: system-darwin,arm-registered-target,aarch64-registered-target
RUN: dsymutil -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat32.dSYM
RUN: llvm-objdump -m --universal-headers %t.fat32.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT32
RUN: dsymutil --linker parallel -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat32.dSYM
RUN: llvm-objdump -m --universal-headers %t.fat32.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT32
RUN: dsymutil -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat64.dSYM -fat64
RUN: llvm-objdump -m --universal-headers %t.fat64.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT64
RUN: dsymutil --linker parallel -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat64.dSYM -fat64
RUN: llvm-objdump -m --universal-headers %t.fat64.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT64
FAT32: fat_magic FAT_MAGIC
FAT64: fat_magic FAT_MAGIC_64

View File

@@ -1,5 +1,7 @@
# RUN: dsymutil -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s
#
# RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s
#
# The YAML debug map bellow is the one from basic-archive.macho.x86_64 with
# the object addresses set to zero. Check that the YAML import is able to
# rewrite these addresses to the right values.

View File

@@ -1041,13 +1041,13 @@ DwarfLinkerForBinary::AddressManager::getRelocValue(const ValidReloc &Reloc) {
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::hasValidRelocationAt(
const std::vector<ValidReloc> &AllRelocs, uint64_t StartOffset,
uint64_t EndOffset) {
uint64_t EndOffset, bool Verbose) {
std::vector<ValidReloc> Relocs =
getRelocations(AllRelocs, StartOffset, EndOffset);
if (Relocs.size() == 0)
return std::nullopt;
if (Linker.Options.Verbose)
if (Verbose)
printReloc(Relocs[0]);
return getRelocValue(Relocs[0]);
@@ -1077,7 +1077,7 @@ getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset,
uint64_t EndOffset) {
uint64_t EndOffset, bool Verbose) {
switch (Op.getCode()) {
default: {
assert(false && "Specified operation does not have address operand");
@@ -1089,11 +1089,13 @@ DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
case dwarf::DW_OP_const4s:
case dwarf::DW_OP_const8s:
case dwarf::DW_OP_addr: {
return hasValidRelocationAt(ValidDebugInfoRelocs, StartOffset, EndOffset);
return hasValidRelocationAt(ValidDebugInfoRelocs, StartOffset, EndOffset,
Verbose);
} break;
case dwarf::DW_OP_constx:
case dwarf::DW_OP_addrx: {
return hasValidRelocationAt(ValidDebugAddrRelocs, StartOffset, EndOffset);
return hasValidRelocationAt(ValidDebugAddrRelocs, StartOffset, EndOffset,
Verbose);
} break;
}
@@ -1102,7 +1104,7 @@ DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
const DWARFDie &DIE) {
const DWARFDie &DIE, bool Verbose) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
std::optional<uint32_t> LowPcIdx =
@@ -1119,7 +1121,7 @@ DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
std::tie(LowPcOffset, LowPcEndOffset) =
getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
return hasValidRelocationAt(ValidDebugInfoRelocs, LowPcOffset,
LowPcEndOffset);
LowPcEndOffset, Verbose);
}
case dwarf::DW_FORM_addrx:
case dwarf::DW_FORM_addrx1:
@@ -1130,9 +1132,9 @@ DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
if (std::optional<uint64_t> AddressOffset =
DIE.getDwarfUnit()->getIndexedAddressOffset(
AddrValue->getRawUValue()))
return hasValidRelocationAt(ValidDebugAddrRelocs, *AddressOffset,
*AddressOffset +
DIE.getDwarfUnit()->getAddressByteSize());
return hasValidRelocationAt(
ValidDebugAddrRelocs, *AddressOffset,
*AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(), Verbose);
Linker.reportWarning("no base offset for address table", SrcFileName);
return std::nullopt;

View File

@@ -192,18 +192,20 @@ private:
/// Checks that there is a relocation in the \p Relocs array against a
/// debug map entry between \p StartOffset and \p NextOffset.
/// Print debug output if \p Verbose is set.
///
/// \returns relocation value if relocation exist, otherwise std::nullopt.
std::optional<int64_t>
hasValidRelocationAt(const std::vector<ValidReloc> &Relocs,
uint64_t StartOffset, uint64_t EndOffset);
uint64_t StartOffset, uint64_t EndOffset,
bool Verbose);
std::optional<int64_t> getExprOpAddressRelocAdjustment(
DWARFUnit &U, const DWARFExpression::Operation &Op,
uint64_t StartOffset, uint64_t EndOffset) override;
uint64_t StartOffset, uint64_t EndOffset, bool Verbose) override;
std::optional<int64_t>
getSubprogramRelocAdjustment(const DWARFDie &DIE) override;
std::optional<int64_t> getSubprogramRelocAdjustment(const DWARFDie &DIE,
bool Verbose) override;
std::optional<StringRef> getLibraryInstallName() override;

View File

@@ -80,8 +80,8 @@ public:
// should be renamed into has valid address ranges
bool hasValidRelocs() override { return HasValidAddressRanges; }
std::optional<int64_t>
getSubprogramRelocAdjustment(const DWARFDie &DIE) override {
std::optional<int64_t> getSubprogramRelocAdjustment(const DWARFDie &DIE,
bool Verbose) override {
assert((DIE.getTag() == dwarf::DW_TAG_subprogram ||
DIE.getTag() == dwarf::DW_TAG_label) &&
"Wrong type of input die");
@@ -101,7 +101,7 @@ public:
std::optional<int64_t>
getExprOpAddressRelocAdjustment(DWARFUnit &U,
const DWARFExpression::Operation &Op,
uint64_t, uint64_t) override {
uint64_t, uint64_t, bool Verbose) override {
switch (Op.getCode()) {
default: {
assert(false && "Specified operation does not have address operand");