[PATCH] [Object/ELF] Provide symbol helpers
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Fri Jun 5 06:20:37 PDT 2015
REPOSITORY
rL LLVM
================
Comment at: include/llvm/Object/ELF.h:1030
@@ +1029,3 @@
+bool ELFFile<ELFT>::isCommonSymbol(const Elf_Sym *Sym) const {
+ return Sym->getType() == llvm::ELF::STT_COMMON ||
+ Sym->st_shndx == llvm::ELF::SHN_COMMON ||
----------------
You don't need the type, just she st_shndx.
================
Comment at: include/llvm/Object/ELF.h:1033
@@ +1032,3 @@
+ /* Hexagon-specific */
+ Sym->st_shndx == llvm::ELF::SHN_HEXAGON_SCOMMON ||
+ Sym->st_shndx == llvm::ELF::SHN_HEXAGON_SCOMMON_1 ||
----------------
This is scary and should probably not be in the common function.
These values can be reused by other architectures to mean something else, no? So they can only be checked in a hexagon only path.
================
Comment at: include/llvm/Object/ELF.h:1042
@@ +1041,3 @@
+bool ELFFile<ELFT>::isDefinedSymbol(const Elf_Sym *Sym) const {
+ return Sym->getType() == llvm::ELF::STT_NOTYPE ||
+ Sym->getType() == llvm::ELF::STT_OBJECT ||
----------------
You only need to check the st_shndx.
My suggestion would be to have predicates that cover all values:
SHN_UNDEF -> isUndefinedSymbol
not SHN_UNDEF and (not in SHN_LORESERVE..SHN_HIRESERVE) except for SHN_XINDEX -> isDefinedSymbol
SHN_LOPROC..SHN_HIOS -> isTargetSpecific
SHN_ABS -> isAbsSymbol
SHN_COMMON ->isAbsSymbol
http://reviews.llvm.org/D10264
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list