Skip to content

[NFC][ELF] Don't duplicate DynamicReloc constructor #150811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: users/jrtc27/spr/main.nfcelf-dont-duplicate-dynamicreloc-constructor
Choose a base branch
from

Conversation

jrtc27
Copy link
Collaborator

@jrtc27 jrtc27 commented Jul 27, 2025

This second constructor is just a shorthand for an AddendOnly relocation
against dummySym with R_ADDEND, so write it as such.

Created using spr 1.3.5
@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2025

@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Author: Jessica Clarke (jrtc27)

Changes

This second constructor is just a shorthand for an AddendOnly relocation
against dummySym with R_ADDEND, so write it as such.


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

1 Files Affected:

  • (modified) lld/ELF/SyntheticSections.h (+2-3)
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 2e7a3c3bc96d2..24ca93fb2b16a 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -442,9 +442,8 @@ class DynamicReloc {
   /// This constructor records a relative relocation with no symbol.
   DynamicReloc(RelType type, const InputSectionBase *inputSec,
                uint64_t offsetInSec, int64_t addend = 0)
-      : sym(inputSec->getCtx().dummySym), inputSec(inputSec),
-        offsetInSec(offsetInSec), type(type), addend(addend), kind(AddendOnly),
-        expr(R_ADDEND) {}
+      : DynamicReloc(type, inputSec, offsetInSec, AddendOnly,
+                     *inputSec->getCtx().dummySym, addend, R_ADDEND) {}
 
   uint64_t getOffset() const;
   uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;

@hstk30-hw hstk30-hw requested a review from MaskRay July 27, 2025 15:43
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.

4 participants