-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[lld][ELF] Annotate Bitfields with Preferred Types #97737
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: Sam Elliott (lenary) ChangesThis makes debugging a little easier. Full diff: https://github.com/llvm/llvm-project/pull/97737.diff 2 Files Affected:
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 58e5306fd6dcd..ec12235f842a9 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -52,14 +52,17 @@ class SectionBase {
Kind kind() const { return (Kind)sectionKind; }
+ LLVM_PREFERRED_TYPE(Kind)
uint8_t sectionKind : 3;
// The next two bit fields are only used by InputSectionBase, but we
// put them here so the struct packs better.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t bss : 1;
// Set for sections that should not be folded by ICF.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t keepUnique : 1;
uint8_t partition = 1;
@@ -282,6 +285,7 @@ struct SectionPiece {
: inputOff(off), live(live), hash(hash >> 1) {}
uint32_t inputOff;
+ LLVM_PREFERRED_TYPE(bool)
uint32_t live : 1;
uint32_t hash : 31;
uint64_t outputOff = 0;
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index c65c5d6cd0dca..e764fe8d73633 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -115,18 +115,21 @@ class Symbol {
uint8_t partition;
// True if this symbol is preemptible at load time.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t isPreemptible : 1;
// True if the symbol was used for linking and thus need to be added to the
// output file's symbol table. This is true for all symbols except for
// unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that
// are unreferenced except by other bitcode objects.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t isUsedInRegularObj : 1;
// True if an undefined or shared symbol is used from a live section.
//
// NOTE: In Writer.cpp the field is used to mark local defined symbols
// which are referenced by relocations when -r or --emit-relocs is given.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t used : 1;
// Used by a Defined symbol with protected or default visibility, to record
@@ -138,27 +141,33 @@ class Symbol {
// - If -shared or --export-dynamic is specified, any symbol in an object
// file/bitcode sets this property, unless suppressed by LTO
// canBeOmittedFromSymbolTable().
+ LLVM_PREFERRED_TYPE(bool)
uint8_t exportDynamic : 1;
// True if the symbol is in the --dynamic-list file. A Defined symbol with
// protected or default visibility with this property is required to be
// exported into .dynsym.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t inDynamicList : 1;
// Used to track if there has been at least one undefined reference to the
// symbol. For Undefined and SharedSymbol, the binding may change to STB_WEAK
// if the first undefined reference from a non-shared object is weak.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t referenced : 1;
// Used to track if this symbol will be referenced after wrapping is performed
// (i.e. this will be true for foo if __real_foo is referenced, and will be
// true for __wrap_foo if foo is referenced).
+ LLVM_PREFERRED_TYPE(bool)
uint8_t referencedAfterWrap : 1;
// True if this symbol is specified by --trace-symbol option.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t traced : 1;
// True if the name contains '@'.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t hasVersionSuffix : 1;
// Symbol visibility. This is the computed minimum visibility of all
@@ -270,13 +279,16 @@ class Symbol {
public:
// True if this symbol is in the Iplt sub-section of the Plt and the Igot
// sub-section of the .got.plt or .got.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t isInIplt : 1;
// True if this symbol needs a GOT entry and its GOT entry is actually in
// Igot. This will be true only for certain non-preemptible ifuncs.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t gotInIgot : 1;
// True if defined relative to a section discarded by ICF.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t folded : 1;
// Allow reuse of a bit between architecture-exclusive symbol flags.
@@ -284,6 +296,7 @@ class Symbol {
// followed by a restore of the toc pointer.
// - isTagged(): On AArch64, true if the symbol needs special relocation and
// metadata semantics because it's tagged, under the AArch64 MemtagABI.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t archSpecificBit : 1;
bool needsTocRestore() const { return archSpecificBit; }
bool isTagged() const { return archSpecificBit; }
@@ -296,13 +309,16 @@ class Symbol {
//
// LTO shouldn't inline the symbol because it doesn't know the final content
// of the symbol.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t scriptDefined : 1;
// True if defined in a DSO. There may also be a definition in a relocatable
// object file.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t dsoDefined : 1;
// True if defined in a DSO as protected visibility.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t dsoProtected : 1;
// Temporary flags used to communicate which symbol entries need PLT and GOT
@@ -319,9 +335,11 @@ class Symbol {
// to a Verneed index in the output. Otherwise, this represents the Verdef
// index (VER_NDX_LOCAL, VER_NDX_GLOBAL, or a named version).
uint16_t versionId;
+ LLVM_PREFERRED_TYPE(bool)
uint8_t versionScriptAssigned : 1;
// True if targeted by a range extension thunk.
+ LLVM_PREFERRED_TYPE(bool)
uint8_t thunkAccessed : 1;
void setFlags(uint16_t bits) {
|
MaskRay
approved these changes
Jul 4, 2024
Member
MaskRay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
swift-ci
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Jul 5, 2024
steven-studio
pushed a commit
to steven-studio/llvm-project
that referenced
this pull request
Sep 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes debugging a little easier.