Skip to content

Commit d2db96c

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.5-bogner
1 parent 29e3c2e commit d2db96c

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

lld/ELF/Symbols.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ class Symbol {
313313
// represents the Verdef index within the input DSO, which will be converted
314314
// to a Verneed index in the output. Otherwise, this represents the Verdef
315315
// index (VER_NDX_LOCAL, VER_NDX_GLOBAL, or a named version).
316+
// VER_NDX_LOCAL indicates a defined symbol that has been localized by a
317+
// version script's local: directive or --exclude-libs.
316318
uint16_t versionId;
317319
LLVM_PREFERRED_TYPE(bool)
318320
uint8_t versionScriptAssigned : 1;

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3784,9 +3784,10 @@ void VersionTableSection::writeTo(uint8_t *buf) {
37843784
buf += 2;
37853785
for (const SymbolTableEntry &s : getPartition(ctx).dynSymTab->getSymbols()) {
37863786
// For an unextracted lazy symbol (undefined weak), it must have been
3787-
// converted to Undefined and have VER_NDX_GLOBAL version here.
3787+
// converted to Undefined.
37883788
assert(!s.sym->isLazy());
3789-
write16(ctx, buf, s.sym->versionId);
3789+
// Undefined symbols should use index 0 when unversioned.
3790+
write16(ctx, buf, s.sym->isUndefined() ? 0 : s.sym->versionId);
37903791
buf += 2;
37913792
}
37923793
}

lld/test/ELF/linkerscript/version-script.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# CHECK-NEXT: Name:
1818
# CHECK-NEXT: }
1919
# CHECK-NEXT: Symbol {
20-
# CHECK-NEXT: Version: 1
20+
# CHECK-NEXT: Version: 0
2121
# CHECK-NEXT: Name: und
2222
# CHECK-NEXT: }
2323
# CHECK-NEXT: Symbol {

lld/test/ELF/version-script-extern-undefined.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# CHECK-NEXT: Name:
1212
# CHECK-NEXT: }
1313
# CHECK-NEXT: Symbol {
14-
# CHECK-NEXT: Version: 1
14+
# CHECK-NEXT: Version: 0
1515
# CHECK-NEXT: Name: _Z3abbi
1616
# CHECK-NEXT: }
1717
# CHECK-NEXT: ]

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,8 @@ enum { VER_FLG_BASE = 0x1, VER_FLG_WEAK = 0x2, VER_FLG_INFO = 0x4 };
17101710

17111711
// Special constants for the version table. (SHT_GNU_versym/.gnu.version)
17121712
enum {
1713-
VER_NDX_LOCAL = 0, // Unversioned local symbol
1714-
VER_NDX_GLOBAL = 1, // Unversioned global symbol
1713+
VER_NDX_LOCAL = 0, // Unversioned undefined or localized defined symbol
1714+
VER_NDX_GLOBAL = 1, // Unversioned non-local defined symbol
17151715
VERSYM_VERSION = 0x7fff, // Version Index mask
17161716
VERSYM_HIDDEN = 0x8000 // Hidden bit (non-default version)
17171717
};

0 commit comments

Comments
 (0)