Skip to content

Commit

Permalink
[ELF] Simplify visibility computation. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Sep 4, 2022
1 parent 498151d commit 86c35a5
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lld/ELF/Symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,6 @@ bool elf::computeIsPreemptible(const Symbol &sym) {
return true;
}

static uint8_t getMinVisibility(uint8_t va, uint8_t vb) {
if (va == STV_DEFAULT)
return vb;
if (vb == STV_DEFAULT)
return va;
return std::min(va, vb);
}

// Merge symbol properties.
//
// When we have many symbols of the same name, we choose one of them,
Expand All @@ -385,8 +377,10 @@ void Symbol::mergeProperties(const Symbol &other) {
exportDynamic = true;

// DSO symbols do not affect visibility in the output.
if (!other.isShared())
visibility = getMinVisibility(visibility, other.visibility);
if (!other.isShared() && other.visibility != STV_DEFAULT)
visibility = visibility == STV_DEFAULT
? other.visibility
: std::min(visibility, other.visibility);
}

void Symbol::resolve(const Symbol &other) {
Expand Down

0 comments on commit 86c35a5

Please sign in to comment.