mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-06 09:44:39 +00:00
[yaml2obj][ELF] Allow symbols to reference sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c18f66e70d
commit
6525e92b32
@ -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