mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Pass MCSymbols to the helper functions in MCELF.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238596 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -19,21 +19,24 @@ | ||||
|  | ||||
| namespace llvm { | ||||
|  | ||||
| void MCELF::SetBinding(MCSymbolData &SD, unsigned Binding) { | ||||
| void MCELF::SetBinding(const MCSymbol &Sym, unsigned Binding) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL || | ||||
|          Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE); | ||||
|   uint32_t OtherFlags = SD.getFlags() & ~(0xf << ELF_STB_Shift); | ||||
|   SD.setFlags(OtherFlags | (Binding << ELF_STB_Shift)); | ||||
| } | ||||
|  | ||||
| unsigned MCELF::GetBinding(const MCSymbolData &SD) { | ||||
| unsigned MCELF::GetBinding(const MCSymbol &Sym) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   uint32_t Binding = (SD.getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift; | ||||
|   assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL || | ||||
|          Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE); | ||||
|   return Binding; | ||||
| } | ||||
|  | ||||
| void MCELF::SetType(MCSymbolData &SD, unsigned Type) { | ||||
| void MCELF::SetType(const MCSymbol &Sym, unsigned Type) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   assert(Type == ELF::STT_NOTYPE || Type == ELF::STT_OBJECT || | ||||
|          Type == ELF::STT_FUNC || Type == ELF::STT_SECTION || | ||||
|          Type == ELF::STT_COMMON || Type == ELF::STT_TLS || | ||||
| @@ -43,7 +46,8 @@ void MCELF::SetType(MCSymbolData &SD, unsigned Type) { | ||||
|   SD.setFlags(OtherFlags | (Type << ELF_STT_Shift)); | ||||
| } | ||||
|  | ||||
| unsigned MCELF::GetType(const MCSymbolData &SD) { | ||||
| unsigned MCELF::GetType(const MCSymbol &Sym) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   uint32_t Type = (SD.getFlags() & (0xf << ELF_STT_Shift)) >> ELF_STT_Shift; | ||||
|   assert(Type == ELF::STT_NOTYPE || Type == ELF::STT_OBJECT || | ||||
|          Type == ELF::STT_FUNC || Type == ELF::STT_SECTION || | ||||
| @@ -53,7 +57,8 @@ unsigned MCELF::GetType(const MCSymbolData &SD) { | ||||
|  | ||||
| // Visibility is stored in the first two bits of st_other | ||||
| // st_other values are stored in the second byte of get/setFlags | ||||
| void MCELF::SetVisibility(MCSymbolData &SD, unsigned Visibility) { | ||||
| void MCELF::SetVisibility(MCSymbol &Sym, unsigned Visibility) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL || | ||||
|          Visibility == ELF::STV_HIDDEN || Visibility == ELF::STV_PROTECTED); | ||||
|  | ||||
| @@ -61,7 +66,8 @@ void MCELF::SetVisibility(MCSymbolData &SD, unsigned Visibility) { | ||||
|   SD.setFlags(OtherFlags | (Visibility << ELF_STV_Shift)); | ||||
| } | ||||
|  | ||||
| unsigned MCELF::GetVisibility(const MCSymbolData &SD) { | ||||
| unsigned MCELF::GetVisibility(const MCSymbol &Sym) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   unsigned Visibility = | ||||
|     (SD.getFlags() & (0x3 << ELF_STV_Shift)) >> ELF_STV_Shift; | ||||
|   assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL || | ||||
| @@ -71,12 +77,14 @@ unsigned MCELF::GetVisibility(const MCSymbolData &SD) { | ||||
|  | ||||
| // Other is stored in the last six bits of st_other | ||||
| // st_other values are stored in the second byte of get/setFlags | ||||
| void MCELF::setOther(MCSymbolData &SD, unsigned Other) { | ||||
| void MCELF::setOther(MCSymbol &Sym, unsigned Other) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   uint32_t OtherFlags = SD.getFlags() & ~(0x3f << ELF_STO_Shift); | ||||
|   SD.setFlags(OtherFlags | (Other << ELF_STO_Shift)); | ||||
| } | ||||
|  | ||||
| unsigned MCELF::getOther(const MCSymbolData &SD) { | ||||
| unsigned MCELF::getOther(const MCSymbol &Sym) { | ||||
|   MCSymbolData &SD = Sym.getData(); | ||||
|   unsigned Other = | ||||
|     (SD.getFlags() & (0x3f << ELF_STO_Shift)) >> ELF_STO_Shift; | ||||
|   return Other; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user