[lld] a2404f1 - [lld-macho] Support renaming of LSDA section
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 10 16:32:03 PST 2021
Author: Jez Ng
Date: 2021-11-10T19:31:54-05:00
New Revision: a2404f11c77e23f4000400e113f46c832406a863
URL: https://github.com/llvm/llvm-project/commit/a2404f11c77e23f4000400e113f46c832406a863
DIFF: https://github.com/llvm/llvm-project/commit/a2404f11c77e23f4000400e113f46c832406a863.diff
LOG: [lld-macho] Support renaming of LSDA section
Previously, our unwind info finalization logic assumed that the LSDA
section referenced by `__compact_unwind` was already finalized before
`__TEXT,__unwind_info` itself. However, that assumption could be broken
by the use of `-rename_section` -- it could be (and is) used to move
`__gcc_except_tab` it into a different segment later in the file.
(__TEXT is always the first non-zerofill segment, so any rename
basically guarantees that the section will be ordered after
`__unwind_info`.)
To handle this case, we compare LSDA relocations instead of their final
values in `UnwindInfoSection::finalize()`, and we actually relocate
those LSDAs in `UnwindInfoSection::writeTo()`. In order to do this, we
need an easy way to track which Symbol a given CUE corresponds to. My
solution was to change our `cuPtrVector` into a vector of indices, with
each index used for both the symbols vector (`symbolsVec`) as well as
the CUE vector (`cuVector`).
This change seems perf neutral. Numbers for linking chromium_framework
on my 16 core Mac Pro:
base diff difference (95% CI)
sys_time 1.248 ± 0.025 1.245 ± 0.026 [ -1.3% .. +0.8%]
user_time 3.588 ± 0.045 3.587 ± 0.037 [ -0.6% .. +0.5%]
wall_time 4.605 ± 0.069 4.595 ± 0.069 [ -1.0% .. +0.5%]
samples 42 26
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D113582
Added:
Modified:
lld/MachO/UnwindInfoSection.cpp
lld/MachO/UnwindInfoSection.h
lld/test/MachO/compact-unwind.s
Removed:
################################################################################
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index f3f7fdbcd0f41..c499826e1059a 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -19,11 +19,13 @@
#include "lld/Common/ErrorHandler.h"
#include "lld/Common/Memory.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Parallel.h"
+#include <numeric>
+
using namespace llvm;
using namespace llvm::MachO;
using namespace lld;
@@ -117,22 +119,27 @@ class UnwindInfoSectionImpl final : public UnwindInfoSection {
public:
void prepareRelocations(ConcatInputSection *) override;
void relocateCompactUnwind(std::vector<CompactUnwindEntry<Ptr>> &);
+ Reloc *findLsdaReloc(ConcatInputSection *) const;
+ void encodePersonalities();
void finalize() override;
void writeTo(uint8_t *buf) const override;
private:
std::vector<std::pair<compact_unwind_encoding_t, size_t>> commonEncodings;
EncodingMap commonEncodingIndexes;
+ // The entries here will be in the same order as their originating symbols
+ // in symbolsVec.
+ std::vector<CompactUnwindEntry<Ptr>> cuEntries;
+ // Indices into the cuEntries vector.
+ std::vector<size_t> cuIndices;
// Indices of personality functions within the GOT.
std::vector<Ptr> personalities;
SmallDenseMap<std::pair<InputSection *, uint64_t /* addend */>, Symbol *>
personalityTable;
- std::vector<unwind_info_section_header_lsda_index_entry> lsdaEntries;
- // Map of function offset (from the image base) to an index within the LSDA
- // array.
- DenseMap<uint32_t, uint32_t> functionToLsdaIndex;
- std::vector<CompactUnwindEntry<Ptr>> cuVector;
- std::vector<CompactUnwindEntry<Ptr> *> cuPtrVector;
+ // Indices into cuEntries for CUEs with a non-null LSDA.
+ std::vector<size_t> entriesWithLsda;
+ // Map of cuEntries index to an index within the LSDA array.
+ DenseMap<size_t, uint32_t> lsdaIndex;
std::vector<SecondLevelPage> secondLevelPages;
uint64_t level2PagesOffset = 0;
};
@@ -277,10 +284,9 @@ static ConcatInputSection *checkTextSegment(InputSection *isec) {
// is no source address to make a relative location meaningful.
template <class Ptr>
void UnwindInfoSectionImpl<Ptr>::relocateCompactUnwind(
- std::vector<CompactUnwindEntry<Ptr>> &cuVector) {
- auto symbolsVec = symbols.takeVector();
+ std::vector<CompactUnwindEntry<Ptr>> &cuEntries) {
parallelForEachN(0, symbolsVec.size(), [&](size_t i) {
- uint8_t *buf = reinterpret_cast<uint8_t *>(cuVector.data()) +
+ uint8_t *buf = reinterpret_cast<uint8_t *>(cuEntries.data()) +
i * sizeof(CompactUnwindEntry<Ptr>);
const Defined *d = symbolsVec[i].second;
// Write the functionAddress.
@@ -314,23 +320,21 @@ void UnwindInfoSectionImpl<Ptr>::relocateCompactUnwind(
// There should only be a handful of unique personality pointers, so we can
// encode them as 2-bit indices into a small array.
-template <class Ptr>
-static void
-encodePersonalities(const std::vector<CompactUnwindEntry<Ptr> *> &cuPtrVector,
- std::vector<Ptr> &personalities) {
- for (CompactUnwindEntry<Ptr> *cu : cuPtrVector) {
- if (cu->personality == 0)
+template <class Ptr> void UnwindInfoSectionImpl<Ptr>::encodePersonalities() {
+ for (size_t idx : cuIndices) {
+ CompactUnwindEntry<Ptr> &cu = cuEntries[idx];
+ if (cu.personality == 0)
continue;
// Linear search is fast enough for a small array.
- auto it = find(personalities, cu->personality);
+ auto it = find(personalities, cu.personality);
uint32_t personalityIndex; // 1-based index
if (it != personalities.end()) {
personalityIndex = std::distance(personalities.begin(), it) + 1;
} else {
- personalities.push_back(cu->personality);
+ personalities.push_back(cu.personality);
personalityIndex = personalities.size();
}
- cu->encoding |=
+ cu.encoding |=
personalityIndex << countTrailingZeros(
static_cast<compact_unwind_encoding_t>(UNWIND_PERSONALITY_MASK));
}
@@ -364,6 +368,20 @@ static bool canFoldEncoding(compact_unwind_encoding_t encoding) {
return true;
}
+template <class Ptr>
+Reloc *
+UnwindInfoSectionImpl<Ptr>::findLsdaReloc(ConcatInputSection *isec) const {
+ if (isec == nullptr)
+ return nullptr;
+ auto it = llvm::find_if(isec->relocs, [](const Reloc &r) {
+ return r.offset % sizeof(CompactUnwindEntry<Ptr>) ==
+ offsetof(CompactUnwindEntry<Ptr>, lsda);
+ });
+ if (it == isec->relocs.end())
+ return nullptr;
+ return &*it;
+}
+
// Scan the __LD,__compact_unwind entries and compute the space needs of
// __TEXT,__unwind_info and __TEXT,__eh_frame
template <class Ptr> void UnwindInfoSectionImpl<Ptr>::finalize() {
@@ -377,46 +395,67 @@ template <class Ptr> void UnwindInfoSectionImpl<Ptr>::finalize() {
// we can fold adjacent CU entries with identical
// encoding+personality+lsda. Folding is necessary because it reduces
// the number of CU entries by as much as 3 orders of magnitude!
- cuVector.resize(symbols.size());
- relocateCompactUnwind(cuVector);
+ cuEntries.resize(symbols.size());
+ // The "map" part of the symbols MapVector was only needed for deduplication
+ // in addSymbol(). Now that we are done adding, move the contents to a plain
+ // std::vector for indexed access.
+ symbolsVec = symbols.takeVector();
+ relocateCompactUnwind(cuEntries);
// Rather than sort & fold the 32-byte entries directly, we create a
- // vector of pointers to entries and sort & fold that instead.
- cuPtrVector.reserve(cuVector.size());
- for (CompactUnwindEntry<Ptr> &cuEntry : cuVector)
- cuPtrVector.emplace_back(&cuEntry);
- llvm::sort(cuPtrVector, [](const CompactUnwindEntry<Ptr> *a,
- const CompactUnwindEntry<Ptr> *b) {
- return a->functionAddress < b->functionAddress;
+ // vector of indices to entries and sort & fold that instead.
+ cuIndices.resize(cuEntries.size());
+ std::iota(cuIndices.begin(), cuIndices.end(), 0);
+ llvm::sort(cuIndices, [&](size_t a, size_t b) {
+ return cuEntries[a].functionAddress < cuEntries[b].functionAddress;
});
// Fold adjacent entries with matching encoding+personality+lsda
- // We use three iterators on the same cuPtrVector to fold in-situ:
+ // We use three iterators on the same cuIndices to fold in-situ:
// (1) `foldBegin` is the first of a potential sequence of matching entries
// (2) `foldEnd` is the first non-matching entry after `foldBegin`.
// The semi-open interval [ foldBegin .. foldEnd ) contains a range
// entries that can be folded into a single entry and written to ...
// (3) `foldWrite`
- auto foldWrite = cuPtrVector.begin();
- for (auto foldBegin = cuPtrVector.begin(); foldBegin < cuPtrVector.end();) {
+ auto foldWrite = cuIndices.begin();
+ for (auto foldBegin = cuIndices.begin(); foldBegin < cuIndices.end();) {
auto foldEnd = foldBegin;
- while (++foldEnd < cuPtrVector.end() &&
- (*foldBegin)->encoding == (*foldEnd)->encoding &&
- (*foldBegin)->personality == (*foldEnd)->personality &&
- (*foldBegin)->lsda == (*foldEnd)->lsda &&
- canFoldEncoding((*foldEnd)->encoding))
- ;
+ while (++foldEnd < cuIndices.end() &&
+ cuEntries[*foldBegin].encoding == cuEntries[*foldEnd].encoding &&
+ cuEntries[*foldBegin].personality ==
+ cuEntries[*foldEnd].personality &&
+ canFoldEncoding(cuEntries[*foldEnd].encoding)) {
+ // In most cases, we can just compare the values of cuEntries[*].lsda.
+ // However, it is possible for -rename_section to cause the LSDA section
+ // (__gcc_except_tab) to be finalized after the unwind info section. In
+ // that case, we don't yet have unique addresses for the LSDA entries.
+ // So we check their relocations instead.
+ // FIXME: should we account for an LSDA at an absolute address? ld64 seems
+ // to support it, but it seems unlikely to be used in practice.
+ Reloc *lsda1 =
+ findLsdaReloc(symbolsVec[*foldBegin].second->compactUnwind);
+ Reloc *lsda2 = findLsdaReloc(symbolsVec[*foldEnd].second->compactUnwind);
+ if (lsda1 == nullptr && lsda2 == nullptr)
+ continue;
+ if (lsda1 == nullptr || lsda2 == nullptr)
+ break;
+ if (lsda1->referent.get<InputSection *>() !=
+ lsda2->referent.get<InputSection *>())
+ break;
+ if (lsda1->addend != lsda2->addend)
+ break;
+ }
*foldWrite++ = *foldBegin;
foldBegin = foldEnd;
}
- cuPtrVector.erase(foldWrite, cuPtrVector.end());
+ cuIndices.erase(foldWrite, cuIndices.end());
- encodePersonalities(cuPtrVector, personalities);
+ encodePersonalities();
// Count frequencies of the folded encodings
EncodingMap encodingFrequencies;
- for (const CompactUnwindEntry<Ptr> *cuPtrEntry : cuPtrVector)
- encodingFrequencies[cuPtrEntry->encoding]++;
+ for (size_t idx : cuIndices)
+ encodingFrequencies[cuEntries[idx].encoding]++;
// Make a vector of encodings, sorted by descending frequency
for (const auto &frequency : encodingFrequencies)
@@ -449,19 +488,21 @@ template <class Ptr> void UnwindInfoSectionImpl<Ptr>::finalize() {
// and 127..255 references a local per-second-level-page table.
// First we try the compact format and determine how many entries fit.
// If more entries fit in the regular format, we use that.
- for (size_t i = 0; i < cuPtrVector.size();) {
+ for (size_t i = 0; i < cuIndices.size();) {
+ size_t idx = cuIndices[i];
secondLevelPages.emplace_back();
SecondLevelPage &page = secondLevelPages.back();
page.entryIndex = i;
uintptr_t functionAddressMax =
- cuPtrVector[i]->functionAddress + COMPRESSED_ENTRY_FUNC_OFFSET_MASK;
+ cuEntries[idx].functionAddress + COMPRESSED_ENTRY_FUNC_OFFSET_MASK;
size_t n = commonEncodings.size();
size_t wordsRemaining =
SECOND_LEVEL_PAGE_WORDS -
sizeof(unwind_info_compressed_second_level_page_header) /
sizeof(uint32_t);
- while (wordsRemaining >= 1 && i < cuPtrVector.size()) {
- const CompactUnwindEntry<Ptr> *cuPtr = cuPtrVector[i];
+ while (wordsRemaining >= 1 && i < cuIndices.size()) {
+ idx = cuIndices[i];
+ const CompactUnwindEntry<Ptr> *cuPtr = &cuEntries[idx];
if (cuPtr->functionAddress >= functionAddressMax) {
break;
} else if (commonEncodingIndexes.count(cuPtr->encoding) ||
@@ -483,34 +524,33 @@ template <class Ptr> void UnwindInfoSectionImpl<Ptr>::finalize() {
// entries by using the regular format. This can happen when there
// are many unique encodings, and we we saturated the local
// encoding table early.
- if (i < cuPtrVector.size() &&
+ if (i < cuIndices.size() &&
page.entryCount < REGULAR_SECOND_LEVEL_ENTRIES_MAX) {
page.kind = UNWIND_SECOND_LEVEL_REGULAR;
page.entryCount = std::min(REGULAR_SECOND_LEVEL_ENTRIES_MAX,
- cuPtrVector.size() - page.entryIndex);
+ cuIndices.size() - page.entryIndex);
i = page.entryIndex + page.entryCount;
} else {
page.kind = UNWIND_SECOND_LEVEL_COMPRESSED;
}
}
- for (const CompactUnwindEntry<Ptr> *cu : cuPtrVector) {
- uint32_t functionOffset = cu->functionAddress - in.header->addr;
- functionToLsdaIndex[functionOffset] = lsdaEntries.size();
- if (cu->lsda != 0)
- lsdaEntries.push_back(
- {functionOffset, static_cast<uint32_t>(cu->lsda - in.header->addr)});
+ for (size_t idx : cuIndices) {
+ const CompactUnwindEntry<Ptr> &cu = cuEntries[idx];
+ lsdaIndex[idx] = entriesWithLsda.size();
+ if (cu.lsda != 0)
+ entriesWithLsda.push_back(idx);
}
// compute size of __TEXT,__unwind_info section
- level2PagesOffset =
- sizeof(unwind_info_section_header) +
- commonEncodings.size() * sizeof(uint32_t) +
- personalities.size() * sizeof(uint32_t) +
- // The extra second-level-page entry is for the sentinel
- (secondLevelPages.size() + 1) *
- sizeof(unwind_info_section_header_index_entry) +
- lsdaEntries.size() * sizeof(unwind_info_section_header_lsda_index_entry);
+ level2PagesOffset = sizeof(unwind_info_section_header) +
+ commonEncodings.size() * sizeof(uint32_t) +
+ personalities.size() * sizeof(uint32_t) +
+ // The extra second-level-page entry is for the sentinel
+ (secondLevelPages.size() + 1) *
+ sizeof(unwind_info_section_header_index_entry) +
+ entriesWithLsda.size() *
+ sizeof(unwind_info_section_header_lsda_index_entry);
unwindInfoSize =
level2PagesOffset + secondLevelPages.size() * SECOND_LEVEL_PAGE_BYTES;
}
@@ -519,7 +559,7 @@ template <class Ptr> void UnwindInfoSectionImpl<Ptr>::finalize() {
template <class Ptr>
void UnwindInfoSectionImpl<Ptr>::writeTo(uint8_t *buf) const {
- assert(!cuPtrVector.empty() && "call only if there is unwind info");
+ assert(!cuIndices.empty() && "call only if there is unwind info");
// section header
auto *uip = reinterpret_cast<unwind_info_section_header *>(buf);
@@ -551,38 +591,45 @@ void UnwindInfoSectionImpl<Ptr>::writeTo(uint8_t *buf) const {
uint64_t l2PagesOffset = level2PagesOffset;
auto *iep = reinterpret_cast<unwind_info_section_header_index_entry *>(i32p);
for (const SecondLevelPage &page : secondLevelPages) {
- iep->functionOffset =
- cuPtrVector[page.entryIndex]->functionAddress - in.header->addr;
+ size_t idx = cuIndices[page.entryIndex];
+ iep->functionOffset = cuEntries[idx].functionAddress - in.header->addr;
iep->secondLevelPagesSectionOffset = l2PagesOffset;
iep->lsdaIndexArraySectionOffset =
- lsdaOffset + functionToLsdaIndex.lookup(iep->functionOffset) *
+ lsdaOffset + lsdaIndex.lookup(idx) *
sizeof(unwind_info_section_header_lsda_index_entry);
iep++;
l2PagesOffset += SECOND_LEVEL_PAGE_BYTES;
}
// Level-1 sentinel
- const CompactUnwindEntry<Ptr> &cuEnd = *cuPtrVector.back();
+ const CompactUnwindEntry<Ptr> &cuEnd = cuEntries[cuIndices.back()];
iep->functionOffset =
cuEnd.functionAddress - in.header->addr + cuEnd.functionLength;
iep->secondLevelPagesSectionOffset = 0;
iep->lsdaIndexArraySectionOffset =
- lsdaOffset +
- lsdaEntries.size() * sizeof(unwind_info_section_header_lsda_index_entry);
+ lsdaOffset + entriesWithLsda.size() *
+ sizeof(unwind_info_section_header_lsda_index_entry);
iep++;
// LSDAs
- size_t lsdaBytes =
- lsdaEntries.size() * sizeof(unwind_info_section_header_lsda_index_entry);
- if (lsdaBytes > 0)
- memcpy(iep, lsdaEntries.data(), lsdaBytes);
+ auto *lep =
+ reinterpret_cast<unwind_info_section_header_lsda_index_entry *>(iep);
+ for (size_t idx : entriesWithLsda) {
+ const CompactUnwindEntry<Ptr> &cu = cuEntries[idx];
+ const Defined *d = symbolsVec[idx].second;
+ if (Reloc *r = findLsdaReloc(d->compactUnwind)) {
+ auto *isec = r->referent.get<InputSection *>();
+ lep->lsdaOffset = isec->getVA(r->addend) - in.header->addr;
+ }
+ lep->functionOffset = cu.functionAddress - in.header->addr;
+ lep++;
+ }
// Level-2 pages
- auto *pp = reinterpret_cast<uint32_t *>(reinterpret_cast<uint8_t *>(iep) +
- lsdaBytes);
+ auto *pp = reinterpret_cast<uint32_t *>(lep);
for (const SecondLevelPage &page : secondLevelPages) {
if (page.kind == UNWIND_SECOND_LEVEL_COMPRESSED) {
uintptr_t functionAddressBase =
- cuPtrVector[page.entryIndex]->functionAddress;
+ cuEntries[cuIndices[page.entryIndex]].functionAddress;
auto *p2p =
reinterpret_cast<unwind_info_compressed_second_level_page_header *>(
pp);
@@ -595,12 +642,13 @@ void UnwindInfoSectionImpl<Ptr>::writeTo(uint8_t *buf) const {
p2p->encodingsCount = page.localEncodings.size();
auto *ep = reinterpret_cast<uint32_t *>(&p2p[1]);
for (size_t i = 0; i < page.entryCount; i++) {
- const CompactUnwindEntry<Ptr> *cuep = cuPtrVector[page.entryIndex + i];
- auto it = commonEncodingIndexes.find(cuep->encoding);
+ const CompactUnwindEntry<Ptr> &cue =
+ cuEntries[cuIndices[page.entryIndex + i]];
+ auto it = commonEncodingIndexes.find(cue.encoding);
if (it == commonEncodingIndexes.end())
- it = page.localEncodingIndexes.find(cuep->encoding);
+ it = page.localEncodingIndexes.find(cue.encoding);
*ep++ = (it->second << COMPRESSED_ENTRY_FUNC_OFFSET_BITS) |
- (cuep->functionAddress - functionAddressBase);
+ (cue.functionAddress - functionAddressBase);
}
if (!page.localEncodings.empty())
memcpy(ep, page.localEncodings.data(),
@@ -614,9 +662,10 @@ void UnwindInfoSectionImpl<Ptr>::writeTo(uint8_t *buf) const {
p2p->entryCount = page.entryCount;
auto *ep = reinterpret_cast<uint32_t *>(&p2p[1]);
for (size_t i = 0; i < page.entryCount; i++) {
- const CompactUnwindEntry<Ptr> *cuep = cuPtrVector[page.entryIndex + i];
- *ep++ = cuep->functionAddress;
- *ep++ = cuep->encoding;
+ const CompactUnwindEntry<Ptr> &cue =
+ cuEntries[cuIndices[page.entryIndex + i]];
+ *ep++ = cue.functionAddress;
+ *ep++ = cue.encoding;
}
}
pp += SECOND_LEVEL_PAGE_WORDS;
diff --git a/lld/MachO/UnwindInfoSection.h b/lld/MachO/UnwindInfoSection.h
index f0d4690b94f9c..e1d60bec077c9 100644
--- a/lld/MachO/UnwindInfoSection.h
+++ b/lld/MachO/UnwindInfoSection.h
@@ -34,6 +34,7 @@ class UnwindInfoSection : public SyntheticSection {
llvm::MapVector<std::pair<const InputSection *, uint64_t /*Defined::value*/>,
const Defined *>
symbols;
+ std::vector<decltype(symbols)::value_type> symbolsVec;
uint64_t unwindInfoSize = 0;
bool allEntriesAreOmitted = true;
};
diff --git a/lld/test/MachO/compact-unwind.s b/lld/test/MachO/compact-unwind.s
index 876268d485037..289bba2a2294f 100644
--- a/lld/test/MachO/compact-unwind.s
+++ b/lld/test/MachO/compact-unwind.s
@@ -3,23 +3,28 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/my-personality.s -o %t/x86_64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/main.s -o %t/x86_64-main.o
# RUN: %lld -arch x86_64 -lSystem -lc++ %t/x86_64-my-personality.o %t/x86_64-main.o -o %t/x86_64-personality-first
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: %lld -dead_strip -arch x86_64 -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/my-personality.s -o %t/arm64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/main.s -o %t/arm64-main.o
# RUN: %lld -arch arm64 -lSystem -lc++ %t/arm64-my-personality.o %t/arm64-main.o -o %t/arm64-personality-first
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: %lld -dead_strip -arch arm64 -lSystem -lc++ %t/arm64-main.o %t/arm64-my-personality.o -o %t/arm64-personality-second
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/my-personality.s -o %t/arm64-32-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/main.s -o %t/arm64-32-main.o
# RUN: %lld-watchos -lSystem -lc++ %t/arm64-32-my-personality.o %t/arm64-32-main.o -o %t/arm64-32-personality-first
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x4000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x4000 -DSEG=__TEXT
# RUN: %lld-watchos -dead_strip -lSystem -lc++ %t/arm64-32-main.o %t/arm64-32-my-personality.o -o %t/arm64-32-personality-second
-# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x4000
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x4000 -DSEG=__TEXT
+
+# RUN: %lld -arch x86_64 -rename_section __TEXT __gcc_except_tab __RODATA __gcc_except_tab -lSystem -lc++ %t/x86_64-my-personality.o %t/x86_64-main.o -o %t/x86_64-personality-first
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -DSEG=__RODATA
+# RUN: %lld -dead_strip -arch x86_64 -rename_section __TEXT __gcc_except_tab __RODATA __gcc_except_tab -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second
+# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000 -DSEG=__RODATA
# FIRST: Indirect symbols for (__DATA_CONST,__got)
# FIRST-NEXT: address index name
@@ -36,8 +41,8 @@
# CHECK-DAG: [[#%x,QUUX:]] g F __TEXT,__text _quux
# CHECK-DAG: [[#%x,FOO:]] l F __TEXT,__text _foo
# CHECK-DAG: [[#%x,BAZ:]] l F __TEXT,__text _baz
-# CHECK-DAG: [[#%x,EXCEPTION0:]] g O __TEXT,__gcc_except_tab _exception0
-# CHECK-DAG: [[#%x,EXCEPTION1:]] g O __TEXT,__gcc_except_tab _exception1
+# CHECK-DAG: [[#%x,EXCEPTION0:]] g O [[SEG]],__gcc_except_tab _exception0
+# CHECK-DAG: [[#%x,EXCEPTION1:]] g O [[SEG]],__gcc_except_tab _exception1
# CHECK: Contents of __unwind_info section:
# CHECK: Personality functions: (count = 2)
More information about the llvm-commits
mailing list