Skip to content

Conversation

@pcc
Copy link
Contributor

@pcc pcc commented Aug 27, 2025

This section type is about to be used by #147424 so let's give it a more
generic name.

pcc added 2 commits August 26, 2025 19:19
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Aug 27, 2025

@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-lld

Author: Peter Collingbourne (pcc)

Changes

This section type is about to be used by #147424 so let's give it a more
generic name.


Full diff: https://github.com/llvm/llvm-project/pull/155540.diff

3 Files Affected:

  • (modified) lld/ELF/SyntheticSections.cpp (+3-4)
  • (modified) lld/ELF/SyntheticSections.h (+2-2)
  • (modified) lld/ELF/Writer.cpp (+3-4)
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 0d87f9a66071a..62d37e2f4ee99 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2775,14 +2775,13 @@ RelroPaddingSection::RelroPaddingSection(Ctx &ctx)
     : SyntheticSection(ctx, ".relro_padding", SHT_NOBITS, SHF_ALLOC | SHF_WRITE,
                        1) {}
 
-RandomizePaddingSection::RandomizePaddingSection(Ctx &ctx, uint64_t size,
-                                                 OutputSection *parent)
-    : SyntheticSection(ctx, ".randomize_padding", SHT_PROGBITS, SHF_ALLOC, 1),
+PaddingSection::PaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent)
+    : SyntheticSection(ctx, ".padding", SHT_PROGBITS, SHF_ALLOC, 1),
       size(size) {
   this->parent = parent;
 }
 
-void RandomizePaddingSection::writeTo(uint8_t *buf) {
+void PaddingSection::writeTo(uint8_t *buf) {
   std::array<uint8_t, 4> filler = getParent()->getFiller(ctx);
   uint8_t *end = buf + size;
   for (; buf + 4 <= end; buf += 4)
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 223dfe3b67b10..e8ab9204513ed 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -784,11 +784,11 @@ class RelroPaddingSection final : public SyntheticSection {
   void writeTo(uint8_t *buf) override {}
 };
 
-class RandomizePaddingSection final : public SyntheticSection {
+class PaddingSection final : public SyntheticSection {
   uint64_t size;
 
 public:
-  RandomizePaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent);
+  PaddingSection(Ctx &ctx, uint64_t size, OutputSection *parent);
   size_t getSize() const override { return size; }
   void writeTo(uint8_t *buf) override;
 };
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4fa80397cbfa7..083b4fb1dbd22 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1495,15 +1495,14 @@ static void randomizeSectionPadding(Ctx &ctx) {
       if (auto *isd = dyn_cast<InputSectionDescription>(bc)) {
         SmallVector<InputSection *, 0> tmp;
         if (os->ptLoad != curPtLoad) {
-          tmp.push_back(make<RandomizePaddingSection>(
-              ctx, g() % ctx.arg.maxPageSize, os));
+          tmp.push_back(
+              make<PaddingSection>(ctx, g() % ctx.arg.maxPageSize, os));
           curPtLoad = os->ptLoad;
         }
         for (InputSection *isec : isd->sections) {
           // Probability of inserting padding is 1 in 16.
           if (g() % 16 == 0)
-            tmp.push_back(
-                make<RandomizePaddingSection>(ctx, isec->addralign, os));
+            tmp.push_back(make<PaddingSection>(ctx, isec->addralign, os));
           tmp.push_back(isec);
         }
         isd->sections = std::move(tmp);

@pcc pcc requested review from MaskRay and smithp35 August 27, 2025 02:21
@MaskRay
Copy link
Member

MaskRay commented Aug 27, 2025

This looks good regardless of the CFI jump table usage.

pcc added 6 commits August 27, 2025 16:16
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@pcc
Copy link
Contributor Author

pcc commented Oct 6, 2025

Ping

@MaskRay
Copy link
Member

MaskRay commented Oct 29, 2025

This should be changed to rebase on top of main and it can be pushed before landing previous patches.

ian-twilightcoder and others added 2 commits October 30, 2025 11:28
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@pcc pcc changed the base branch from users/pcc/spr/main.elf-rename-randomizepaddingsection-to-paddingsection to main October 30, 2025 18:28
@pcc pcc merged commit 87673d3 into main Oct 30, 2025
8 of 16 checks passed
@pcc pcc deleted the users/pcc/spr/elf-rename-randomizepaddingsection-to-paddingsection branch October 30, 2025 18:28
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 30, 2025
This section type is about to be used by #147424 so let's give it a more
generic name.

Reviewers: smithp35, MaskRay

Reviewed By: MaskRay

Pull Request: llvm/llvm-project#155540
luciechoi pushed a commit to luciechoi/llvm-project that referenced this pull request Nov 1, 2025
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
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants