mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[yaml2obj][ELF] Allow symbols to reference sections.
llvm-svn: 184468
This commit is contained in:
parent
b36f148890
commit
b8315826cf
@ -57,6 +57,7 @@ struct Symbol {
|
||||
StringRef Name;
|
||||
ELF_STB Binding;
|
||||
ELF_STT Type;
|
||||
StringRef Section;
|
||||
};
|
||||
struct Section {
|
||||
StringRef Name;
|
||||
|
@ -315,6 +315,7 @@ void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
|
||||
IO.mapOptional("Name", Symbol.Name, StringRef());
|
||||
IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
|
||||
IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
|
||||
IO.mapOptional("Section", Symbol.Section, StringRef());
|
||||
}
|
||||
|
||||
void MappingTraits<ELFYAML::Section>::mapping(IO &IO,
|
||||
|
@ -15,6 +15,7 @@ Sections:
|
||||
- Name: main
|
||||
Binding: STB_GLOBAL
|
||||
Type: STT_FUNC
|
||||
Section: .text
|
||||
|
||||
# CHECK: Symbols [
|
||||
# CHECK-NEXT: Symbol {
|
||||
@ -23,3 +24,4 @@ Sections:
|
||||
# CHECK-NEXT: Name: main
|
||||
# CHECK: Binding: Global
|
||||
# CHECK-NEXT: Type: Function
|
||||
# CHECK: Section: .text
|
||||
|
@ -199,6 +199,13 @@ static void handleSymtabSectionHeader(
|
||||
if (!Sym.Name.empty())
|
||||
Symbol.st_name = State.getStringTable().addString(Sym.Name);
|
||||
Symbol.setBindingAndType(Sym.Binding, Sym.Type);
|
||||
unsigned Index;
|
||||
if (State.getSN2I().lookupSection(Sym.Section, Index)) {
|
||||
errs() << "error: Unknown section referenced: '" << Sym.Section
|
||||
<< "' by YAML symbol " << Sym.Name << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
Symbol.st_shndx = Index;
|
||||
Syms.push_back(Symbol);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user