@@ -93,10 +93,6 @@ class Symbol {
93
93
// The partition whose dynamic symbol table contains this symbol's definition.
94
94
uint8_t partition = 1 ;
95
95
96
- // Symbol visibility. This is the computed minimum visibility of all
97
- // observed non-DSO symbols.
98
- uint8_t visibility : 2 ;
99
-
100
96
// True if this symbol is preemptible at load time.
101
97
uint8_t isPreemptible : 1 ;
102
98
@@ -146,6 +142,13 @@ class Symbol {
146
142
147
143
inline void replace (const Symbol &other);
148
144
145
+ // Symbol visibility. This is the computed minimum visibility of all
146
+ // observed non-DSO symbols.
147
+ uint8_t visibility () const { return stOther & 3 ; }
148
+ void setVisibility (uint8_t visibility) {
149
+ stOther = (stOther & ~3 ) | visibility;
150
+ }
151
+
149
152
bool includeInDynsym () const ;
150
153
uint8_t computeBinding () const ;
151
154
bool isGlobal () const { return binding == llvm::ELF::STB_GLOBAL; }
@@ -244,16 +247,15 @@ class Symbol {
244
247
Symbol (Kind k, InputFile *file, StringRef name, uint8_t binding,
245
248
uint8_t stOther, uint8_t type)
246
249
: file(file), nameData(name.data()), nameSize(name.size()), type(type),
247
- binding (binding), stOther(stOther), symbolKind(k),
248
- visibility(stOther & 3 ), isPreemptible(false ),
250
+ binding (binding), stOther(stOther), symbolKind(k), isPreemptible(false ),
249
251
isUsedInRegularObj(false ), used(false ), exportDynamic(false ),
250
252
inDynamicList(false ), referenced(false ), referencedAfterWrap(false ),
251
253
traced(false ), hasVersionSuffix(false ), isInIplt(false ),
252
254
gotInIgot(false ), folded(false ), needsTocRestore(false ),
253
- scriptDefined(false ), needsCopy (false ), needsGot (false ),
254
- needsPlt (false ), needsTlsDesc (false ), needsTlsGd (false ),
255
- needsTlsGdToIe (false ), needsGotDtprel (false ), needsTlsIe (false ),
256
- hasDirectReloc(false ) {}
255
+ scriptDefined(false ), dsoProtected (false ), needsCopy (false ),
256
+ needsGot (false ), needsPlt (false ), needsTlsDesc (false ),
257
+ needsTlsGd (false ), needsTlsGdToIe (false ), needsGotDtprel (false ),
258
+ needsTlsIe( false ), hasDirectReloc(false ) {}
257
259
258
260
public:
259
261
// True if this symbol is in the Iplt sub-section of the Plt and the Igot
@@ -277,6 +279,9 @@ class Symbol {
277
279
// of the symbol.
278
280
uint8_t scriptDefined : 1 ;
279
281
282
+ // True if defined in a DSO as protected visibility.
283
+ uint8_t dsoProtected : 1 ;
284
+
280
285
// True if this symbol needs a canonical PLT entry, or (during
281
286
// postScanRelocations) a copy relocation.
282
287
uint8_t needsCopy : 1 ;
@@ -398,6 +403,7 @@ class SharedSymbol : public Symbol {
398
403
: Symbol(SharedKind, &file, name, binding, stOther, type), value(value),
399
404
size (size), alignment(alignment) {
400
405
exportDynamic = true ;
406
+ dsoProtected = visibility () == llvm::ELF::STV_PROTECTED;
401
407
// GNU ifunc is a mechanism to allow user-supplied functions to
402
408
// resolve PLT slot values at load-time. This is contrary to the
403
409
// regular symbol resolution scheme in which symbols are resolved just
@@ -527,7 +533,7 @@ void Symbol::replace(const Symbol &other) {
527
533
nameData = old.nameData ;
528
534
nameSize = old.nameSize ;
529
535
partition = old.partition ;
530
- visibility = old.visibility ;
536
+ setVisibility ( old.visibility ()) ;
531
537
isPreemptible = old.isPreemptible ;
532
538
isUsedInRegularObj = old.isUsedInRegularObj ;
533
539
exportDynamic = old.exportDynamic ;
0 commit comments