Skip to content

Commit 3747b5a

Browse files
committed
Merge remote-tracking branch 'parent/main' into wasmlibunwindfix
2 parents f1e8406 + a87f776 commit 3747b5a

File tree

18 files changed

+516
-198
lines changed

18 files changed

+516
-198
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Deprecations and Removals
102102
headers as an extension and only deprecates them. The ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
103103
suppress deprecation for these headers.
104104

105+
- The ``_LIBCPP_DISABLE_AVAILABILITY`` macro that was used to force-disable availability markup has now been removed.
106+
Whether availability markup is used by the library is now solely controlled at configuration-time.
107+
105108
Upcoming Deprecations and Removals
106109
----------------------------------
107110

libcxx/include/__configuration/availability.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@
6767
//
6868
// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
6969

70-
// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
71-
// for a while.
72-
#if defined(_LIBCPP_DISABLE_AVAILABILITY)
73-
# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
74-
# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
75-
#endif
76-
7770
// Availability markup is disabled when building the library, or when a non-Clang
7871
// compiler is used because only Clang supports the necessary attributes.
7972
#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)

lld/ELF/AArch64ErrataFix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ class elf::Patch843419Section final : public SyntheticSection {
393393
};
394394

395395
Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off)
396-
: SyntheticSection(ctx, SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
397-
".text.patch"),
396+
: SyntheticSection(ctx, ".text.patch", SHT_PROGBITS,
397+
SHF_ALLOC | SHF_EXECINSTR, 4),
398398
patchee(p), patcheeOffset(off) {
399399
this->parent = p->getParent();
400400
patchSym = addSyntheticLocal(

lld/ELF/ARMErrataFix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ static bool is32bitBranch(uint32_t instr) {
136136

137137
Patch657417Section::Patch657417Section(Ctx &ctx, InputSection *p, uint64_t off,
138138
uint32_t instr, bool isARM)
139-
: SyntheticSection(ctx, SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
140-
".text.patch"),
139+
: SyntheticSection(ctx, ".text.patch", SHT_PROGBITS,
140+
SHF_ALLOC | SHF_EXECINSTR, 4),
141141
patchee(p), patcheeOffset(off), instr(instr), isARM(isARM) {
142142
parent = p->getParent();
143143
patchSym = addSyntheticLocal(

lld/ELF/Arch/ARM.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,9 +1331,9 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
13311331
}
13321332

13331333
ArmCmseSGSection::ArmCmseSGSection(Ctx &ctx)
1334-
: SyntheticSection(ctx, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
1335-
llvm::ELF::SHT_PROGBITS,
1336-
/*alignment=*/32, ".gnu.sgstubs") {
1334+
: SyntheticSection(ctx, ".gnu.sgstubs", SHT_PROGBITS,
1335+
SHF_ALLOC | SHF_EXECINSTR,
1336+
/*addralign=*/32) {
13371337
entsize = ACLESESYM_SIZE;
13381338
// The range of addresses used in the CMSE import library should be fixed.
13391339
for (auto &[_, sym] : ctx.symtab->cmseImportLib) {
@@ -1445,21 +1445,22 @@ void ArmCmseSGSection::finalizeContents() {
14451445
// See Arm® v8-M Security Extensions: Requirements on Development Tools
14461446
// https://developer.arm.com/documentation/ecm0359818/latest
14471447
template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
1448-
StringTableSection *shstrtab =
1449-
make<StringTableSection>(ctx, ".shstrtab", /*dynamic=*/false);
1450-
StringTableSection *strtab =
1451-
make<StringTableSection>(ctx, ".strtab", /*dynamic=*/false);
1452-
SymbolTableBaseSection *impSymTab =
1453-
make<SymbolTableSection<ELFT>>(ctx, *strtab);
1448+
auto shstrtab =
1449+
std::make_unique<StringTableSection>(ctx, ".shstrtab", /*dynamic=*/false);
1450+
auto strtab =
1451+
std::make_unique<StringTableSection>(ctx, ".strtab", /*dynamic=*/false);
1452+
auto impSymTab = std::make_unique<SymbolTableSection<ELFT>>(ctx, *strtab);
14541453

14551454
SmallVector<std::pair<std::unique_ptr<OutputSection>, SyntheticSection *>, 0>
14561455
osIsPairs;
14571456
osIsPairs.emplace_back(
1458-
std::make_unique<OutputSection>(ctx, strtab->name, 0, 0), strtab);
1457+
std::make_unique<OutputSection>(ctx, strtab->name, 0, 0), strtab.get());
14591458
osIsPairs.emplace_back(
1460-
std::make_unique<OutputSection>(ctx, impSymTab->name, 0, 0), impSymTab);
1459+
std::make_unique<OutputSection>(ctx, impSymTab->name, 0, 0),
1460+
impSymTab.get());
14611461
osIsPairs.emplace_back(
1462-
std::make_unique<OutputSection>(ctx, shstrtab->name, 0, 0), shstrtab);
1462+
std::make_unique<OutputSection>(ctx, shstrtab->name, 0, 0),
1463+
shstrtab.get());
14631464

14641465
llvm::sort(ctx.symtab->cmseSymMap, [&](const auto &a, const auto &b) {
14651466
return a.second.sym->getVA(ctx) < b.second.sym->getVA(ctx);

lld/ELF/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ namespace {
10451045
class RISCVAttributesSection final : public SyntheticSection {
10461046
public:
10471047
RISCVAttributesSection(Ctx &ctx)
1048-
: SyntheticSection(ctx, 0, SHT_RISCV_ATTRIBUTES, 1, ".riscv.attributes") {
1048+
: SyntheticSection(ctx, ".riscv.attributes", SHT_RISCV_ATTRIBUTES, 0, 1) {
10491049
}
10501050

10511051
size_t getSize() const override { return size; }

lld/ELF/Driver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,8 +2375,9 @@ static void markAddrsig(bool icfSafe, Symbol *s) {
23752375
// We don't need to keep text sections unique under --icf=all even if they
23762376
// are address-significant.
23772377
if (auto *d = dyn_cast_or_null<Defined>(s))
2378-
if (d->section && (icfSafe || !(d->section->flags & SHF_EXECINSTR)))
2379-
d->section->keepUnique = true;
2378+
if (auto *sec = dyn_cast_or_null<InputSectionBase>(d->section))
2379+
if (icfSafe || !(sec->flags & SHF_EXECINSTR))
2380+
sec->keepUnique = true;
23802381
}
23812382

23822383
// Record sections that define symbols mentioned in --keep-unique <symbol>
@@ -2391,7 +2392,8 @@ static void findKeepUniqueSections(Ctx &ctx, opt::InputArgList &args) {
23912392
Warn(ctx) << "could not find symbol " << name << " to keep unique";
23922393
continue;
23932394
}
2394-
d->section->keepUnique = true;
2395+
if (auto *sec = dyn_cast<InputSectionBase>(d->section))
2396+
sec->keepUnique = true;
23952397
}
23962398

23972399
// --icf=all --ignore-data-address-equality means that we can ignore

lld/ELF/InputSection.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ InputSectionBase::InputSectionBase(InputFile *file, StringRef name,
5959
Kind sectionKind)
6060
: SectionBase(sectionKind, file, name, type, flags, link, info, addralign,
6161
entsize),
62+
bss(0), decodedCrel(0), keepUnique(0), nopFiller(0),
6263
content_(data.data()), size(data.size()) {
6364
// In order to reduce memory allocation, we assume that mergeable
6465
// sections are smaller than 4 GiB, which is not an unreasonable

lld/ELF/InputSection.h

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,17 @@ template <class ELFT> struct RelsOrRelas {
5959
// sections.
6060
class SectionBase {
6161
public:
62-
enum Kind { Regular, Synthetic, Spill, EHFrame, Merge, Output, Class };
63-
64-
Kind kind() const { return (Kind)sectionKind; }
65-
66-
LLVM_PREFERRED_TYPE(Kind)
67-
uint8_t sectionKind : 3;
68-
69-
// The next two bit fields are only used by InputSectionBase, but we
70-
// put them here so the struct packs better.
71-
72-
LLVM_PREFERRED_TYPE(bool)
73-
uint8_t bss : 1;
74-
75-
// Set for sections that should not be folded by ICF.
76-
LLVM_PREFERRED_TYPE(bool)
77-
uint8_t keepUnique : 1;
62+
enum Kind : uint8_t {
63+
Regular,
64+
Synthetic,
65+
Spill,
66+
EHFrame,
67+
Merge,
68+
Output,
69+
Class,
70+
};
7871

79-
uint8_t partition = 1;
80-
uint32_t type;
72+
Kind kind() const { return sectionKind; }
8173

8274
// The file which contains this section. For InputSectionBase, its dynamic
8375
// type is usually ObjFile<ELFT>, but may be an InputFile of InternalKind
@@ -93,11 +85,18 @@ class SectionBase {
9385

9486
// These corresponds to the fields in Elf_Shdr.
9587
uint64_t flags;
88+
uint32_t type;
9689
uint32_t link;
9790
uint32_t info;
9891
uint32_t addralign;
9992
uint32_t entsize;
10093

94+
Kind sectionKind;
95+
uint8_t partition = 1;
96+
97+
// The next two bit fields are only used by InputSectionBase, but we
98+
// put them here so the struct packs better.
99+
101100
Ctx &getCtx() const;
102101
OutputSection *getOutputSection();
103102
const OutputSection *getOutputSection() const {
@@ -118,9 +117,9 @@ class SectionBase {
118117
constexpr SectionBase(Kind sectionKind, InputFile *file, StringRef name,
119118
uint32_t type, uint64_t flags, uint32_t link,
120119
uint32_t info, uint32_t addralign, uint32_t entsize)
121-
: sectionKind(sectionKind), bss(false), keepUnique(false), type(type),
122-
file(file), name(name), flags(flags), link(link), info(info),
123-
addralign(addralign), entsize(entsize) {}
120+
: file(file), name(name), flags(flags), type(type), link(link),
121+
info(info), addralign(addralign), entsize(entsize),
122+
sectionKind(sectionKind) {}
124123
};
125124

126125
struct SymbolAnchor {
@@ -157,6 +156,25 @@ class InputSectionBase : public SectionBase {
157156
return s->kind() != Output && s->kind() != Class;
158157
}
159158

159+
LLVM_PREFERRED_TYPE(bool)
160+
uint8_t bss : 1;
161+
162+
// Whether this section is SHT_CREL and has been decoded to RELA by
163+
// relsOrRelas.
164+
LLVM_PREFERRED_TYPE(bool)
165+
uint8_t decodedCrel : 1;
166+
167+
// Set for sections that should not be folded by ICF.
168+
LLVM_PREFERRED_TYPE(bool)
169+
uint8_t keepUnique : 1;
170+
171+
// Whether the section needs to be padded with a NOP filler due to
172+
// deleteFallThruJmpInsn.
173+
LLVM_PREFERRED_TYPE(bool)
174+
uint8_t nopFiller : 1;
175+
176+
mutable bool compressed = false;
177+
160178
// Input sections are part of an output section. Special sections
161179
// like .eh_frame and merge sections are first combined into a
162180
// synthetic section that is then added to an output section. In all
@@ -176,16 +194,6 @@ class InputSectionBase : public SectionBase {
176194
// be reset to zero after uses.
177195
uint32_t bytesDropped = 0;
178196

179-
mutable bool compressed = false;
180-
181-
// Whether this section is SHT_CREL and has been decoded to RELA by
182-
// relsOrRelas.
183-
bool decodedCrel = false;
184-
185-
// Whether the section needs to be padded with a NOP filler due to
186-
// deleteFallThruJmpInsn.
187-
bool nopFiller = false;
188-
189197
void drop_back(unsigned num) {
190198
assert(bytesDropped + num < 256);
191199
bytesDropped += num;
@@ -467,13 +475,13 @@ class PotentialSpillSection : public InputSection {
467475
}
468476
};
469477

470-
static_assert(sizeof(InputSection) <= 160, "InputSection is too big");
478+
static_assert(sizeof(InputSection) <= 152, "InputSection is too big");
471479

472480
class SyntheticSection : public InputSection {
473481
public:
474482
Ctx &ctx;
475-
SyntheticSection(Ctx &ctx, uint64_t flags, uint32_t type, uint32_t addralign,
476-
StringRef name)
483+
SyntheticSection(Ctx &ctx, StringRef name, uint32_t type, uint64_t flags,
484+
uint32_t addralign)
477485
: InputSection(ctx.internalFile, name, type, flags, addralign,
478486
/*entsize=*/0, {}, InputSectionBase::Synthetic),
479487
ctx(ctx) {}

lld/ELF/LinkerScript.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ OutputDesc *LinkerScript::createOutputSection(StringRef name,
145145
// There was a forward reference.
146146
sec = secRef;
147147
} else {
148-
sec = make<OutputDesc>(ctx, name, SHT_PROGBITS, 0);
148+
descPool.emplace_back(
149+
std::make_unique<OutputDesc>(ctx, name, SHT_PROGBITS, 0));
150+
sec = descPool.back().get();
149151
if (!secRef)
150152
secRef = sec;
151153
}
@@ -154,10 +156,14 @@ OutputDesc *LinkerScript::createOutputSection(StringRef name,
154156
}
155157

156158
OutputDesc *LinkerScript::getOrCreateOutputSection(StringRef name) {
157-
OutputDesc *&cmdRef = nameToOutputSection[CachedHashStringRef(name)];
158-
if (!cmdRef)
159-
cmdRef = make<OutputDesc>(ctx, name, SHT_PROGBITS, 0);
160-
return cmdRef;
159+
auto &secRef = nameToOutputSection[CachedHashStringRef(name)];
160+
if (!secRef) {
161+
secRef = descPool
162+
.emplace_back(
163+
std::make_unique<OutputDesc>(ctx, name, SHT_PROGBITS, 0))
164+
.get();
165+
}
166+
return secRef;
161167
}
162168

163169
// Expands the memory region by the specified size.

0 commit comments

Comments
 (0)