llvm.org GIT mirror llvm / 6525e92
[yaml2obj][ELF] Allow symbols to reference sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184468 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 7 years ago
4 changed file(s) with 11 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5656 StringRef Name;
5757 ELF_STB Binding;
5858 ELF_STT Type;
59 StringRef Section;
5960 };
6061 struct Section {
6162 StringRef Name;
314314 IO.mapOptional("Name", Symbol.Name, StringRef());
315315 IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
316316 IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
317 IO.mapOptional("Section", Symbol.Section, StringRef());
317318 }
318319
319320 void MappingTraits::mapping(IO &IO,
1414 - Name: main
1515 Binding: STB_GLOBAL
1616 Type: STT_FUNC
17 Section: .text
1718
1819 # CHECK: Symbols [
1920 # CHECK-NEXT: Symbol {
2223 # CHECK-NEXT: Name: main
2324 # CHECK: Binding: Global
2425 # CHECK-NEXT: Type: Function
26 # CHECK: Section: .text
198198 if (!Sym.Name.empty())
199199 Symbol.st_name = State.getStringTable().addString(Sym.Name);
200200 Symbol.setBindingAndType(Sym.Binding, Sym.Type);
201 unsigned Index;
202 if (State.getSN2I().lookupSection(Sym.Section, Index)) {
203 errs() << "error: Unknown section referenced: '" << Sym.Section
204 << "' by YAML symbol " << Sym.Name << ".\n";
205 exit(1);
206 }
207 Symbol.st_shndx = Index;
201208 Syms.push_back(Symbol);
202209 }
203210