Skip to content

Commit 87673d3

Browse files
authored
ELF: Rename RandomizePaddingSection to PaddingSection.
This section type is about to be used by llvm#147424 so let's give it a more generic name. Reviewers: smithp35, MaskRay Reviewed By: MaskRay Pull Request: llvm#155540
1 parent 28e98b8 commit 87673d3

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,14 +2749,13 @@ RelroPaddingSection::RelroPaddingSection(Ctx &ctx)
27492749
: SyntheticSection(ctx, ".relro_padding", SHT_NOBITS, SHF_ALLOC | SHF_WRITE,
27502750
1) {}
27512751

2752-
RandomizePaddingSection::RandomizePaddingSection(Ctx &ctx, uint64_t size,
2753-
OutputSection *parent)
2754-
: SyntheticSection(ctx, ".randomize_padding", SHT_PROGBITS, SHF_ALLOC, 1),
2752+
PaddingSection::PaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent)
2753+
: SyntheticSection(ctx, ".padding", SHT_PROGBITS, SHF_ALLOC, 1),
27552754
size(size) {
27562755
this->parent = parent;
27572756
}
27582757

2759-
void RandomizePaddingSection::writeTo(uint8_t *buf) {
2758+
void PaddingSection::writeTo(uint8_t *buf) {
27602759
std::array<uint8_t, 4> filler = getParent()->getFiller(ctx);
27612760
uint8_t *end = buf + size;
27622761
for (; buf + 4 <= end; buf += 4)

lld/ELF/SyntheticSections.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,11 @@ class RelroPaddingSection final : public SyntheticSection {
779779
void writeTo(uint8_t *buf) override {}
780780
};
781781

782-
class RandomizePaddingSection final : public SyntheticSection {
782+
class PaddingSection final : public SyntheticSection {
783783
uint64_t size;
784784

785785
public:
786-
RandomizePaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent);
786+
PaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent);
787787
size_t getSize() const override { return size; }
788788
void writeTo(uint8_t *buf) override;
789789
};

lld/ELF/Writer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,15 +1495,14 @@ static void randomizeSectionPadding(Ctx &ctx) {
14951495
if (auto *isd = dyn_cast<InputSectionDescription>(bc)) {
14961496
SmallVector<InputSection *, 0> tmp;
14971497
if (os->ptLoad != curPtLoad) {
1498-
tmp.push_back(make<RandomizePaddingSection>(
1499-
ctx, g() % ctx.arg.maxPageSize, os));
1498+
tmp.push_back(
1499+
make<PaddingSection>(ctx, g() % ctx.arg.maxPageSize, os));
15001500
curPtLoad = os->ptLoad;
15011501
}
15021502
for (InputSection *isec : isd->sections) {
15031503
// Probability of inserting padding is 1 in 16.
15041504
if (g() % 16 == 0)
1505-
tmp.push_back(
1506-
make<RandomizePaddingSection>(ctx, isec->addralign, os));
1505+
tmp.push_back(make<PaddingSection>(ctx, isec->addralign, os));
15071506
tmp.push_back(isec);
15081507
}
15091508
isd->sections = std::move(tmp);

0 commit comments

Comments
 (0)