Skip to content

Commit a253ca3

Browse files
committed
Debug extra symbols
1 parent fd0028d commit a253ca3

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

lld/ELF/Arch/SBF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SBF::SBF() {
4141
symbolicRel = R_SBF_64_64;
4242
defaultCommonPageSize = 8;
4343
defaultMaxPageSize = 8;
44-
defaultImageBase = 8;
44+
defaultImageBase = 0;
4545
}
4646

4747
RelExpr SBF::getRelExpr(RelType type, const Symbol &s,

lld/ELF/SyntheticSections.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ Defined *elf::addSyntheticLocal(StringRef name, uint8_t type, uint64_t value,
272272
Defined *s = makeDefined(section.file, name, STB_LOCAL, STV_DEFAULT, type,
273273
value, size, &section);
274274
if (in.symTab) {
275-
std::ofstream out("/Users/lucasste/Documents/solana-test/program/addsyn.txt", std::ios::app);
276-
out << s->getName().str() << std::endl;
277275
in.symTab->addSymbol(s);
278276
}
279277

@@ -2178,7 +2176,7 @@ void SymbolTableBaseSection::addSymbol(Symbol *b) {
21782176
(config->emachine == EM_SBF && config->eflags == 0x3));
21792177

21802178
unsigned Offset;
2181-
if (strTabSec.name == ".dynstr" && b->isLocal()) {
2179+
if (this->type == SHT_DYNSYM && b->isLocal()) {
21822180
const static unsigned LocalOffset = strTabSec.addString("hidden_func", false);
21832181
Offset = LocalOffset;
21842182
} else {

lld/ELF/SyntheticSections.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/Support/Endian.h"
3232
#include "llvm/Support/Parallel.h"
3333
#include "llvm/Support/Threading.h"
34+
#include <unordered_set>
3435

3536
namespace lld::elf {
3637
class Defined;

lld/ELF/Writer.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,11 @@ static void demoteAndCopyLocalSymbols() {
786786
if (isSbfV3() &&
787787
includeInSymtab(*b) &&
788788
shouldKeepInSymtab(*dr) &&
789-
(b->used || (!config->gcSections && (!config->copyRelocs || config->discard == DiscardPolicy::None)))) {
790-
if ((b->type & STT_FUNC) != 0) {
789+
(b->used || (!config->gcSections && (!config->copyRelocs || config->discard == DiscardPolicy::None))) &&
790+
b->type == STT_FUNC) {
791791
// std::ofstream out("/Users/lucasste/Documents/solana-test/program/demote.txt", std::ios::app);
792792
// out << "Adding sym: " << b->getName().str() << std::endl;
793-
partitions[b->partition - 1].dynSymTab->addSymbol(b);
794-
}
793+
partitions[b->partition - 1].dynSymTab->addSymbol(b);
795794
}
796795
}
797796
}
@@ -1712,6 +1711,7 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
17121711
AArch64Err843419Patcher a64p;
17131712
ARMErr657417Patcher a32p;
17141713
script->assignAddresses();
1714+
bool SbfDuplicateRemoval = false;
17151715
// .ARM.exidx and SHF_LINK_ORDER do not require precise addresses, but they
17161716
// do require the relative addresses of OutputSections because linker scripts
17171717
// can assign Virtual Addresses to OutputSections that are not monotonically
@@ -1762,6 +1762,15 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
17621762
}
17631763

17641764
const Defined *changedSym = script->assignAddresses();
1765+
1766+
if (!SbfDuplicateRemoval && isSbfV3()) {
1767+
for (Partition &part: partitions) {
1768+
part.dynSymTab->sortSymbolsByValue();
1769+
}
1770+
SbfDuplicateRemoval = true;
1771+
changed = true;
1772+
}
1773+
17651774
if (!changed) {
17661775
// Some symbols may be dependent on section addresses. When we break the
17671776
// loop, the symbol values are finalized because a previous
@@ -2104,7 +2113,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
21042113
addVerneed(sym);
21052114
} else if (isSbfV3() &&
21062115
(sym->used || (!config->gcSections && (!config->copyRelocs || config->discard == DiscardPolicy::None))) &&
2107-
(sym->type & STT_FUNC) != 0) {
2116+
sym->type == STT_FUNC) {
21082117
partitions[sym->partition - 1].dynSymTab->addSymbol(sym);
21092118
}
21102119
}
@@ -2300,11 +2309,12 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
23002309
if (config->emachine == EM_ARM && !config->isLE && config->armBe8) {
23012310
addArmInputSectionMappingSymbols();
23022311
sortArmMappingSymbols();
2303-
} else if (isSbfV3()) {
2304-
for (Partition &part: partitions) {
2305-
part.dynSymTab->sortSymbolsByValue();
2306-
}
23072312
}
2313+
// else if (isSbfV3()) {
2314+
// for (Partition &part: partitions) {
2315+
// part.dynSymTab->sortSymbolsByValue();
2316+
// }
2317+
// }
23082318
}
23092319

23102320
// Ensure data sections are not mixed with executable sections when

0 commit comments

Comments
 (0)