Skip to content

Instantly share code, notes, and snippets.

@rui314
Created November 28, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rui314/6382995c81689668961caf49a0e695f9 to your computer and use it in GitHub Desktop.
Save rui314/6382995c81689668961caf49a0e695f9 to your computer and use it in GitHub Desktop.
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 9f4554e1d63d..8df7926ac63c 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1955,9 +1955,13 @@ static uint32_t getSymSectionIndex(Symbol *Sym) {
return SHN_COMMON;
if (!isa<Defined>(Sym) || Sym->NeedsPltAddr)
return SHN_UNDEF;
- if (const OutputSection *OS = Sym->getOutputSection())
- return OS->SectionIndex >= SHN_LORESERVE ? (uint32_t)SHN_XINDEX
- : OS->SectionIndex;
+ if (const OutputSection *OS = Sym->getOutputSection()) {
+ if (OS->SectionIndex == UINT32_MAX)
+ return 1;
+ if (OS->SectionIndex >= SHN_LORESERVE)
+ return (uint32_t)SHN_XINDEX;
+ return OS->SectionIndex;
+ }
return SHN_ABS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment