llvm.org GIT mirror llvm / e38f640
[yaml2obj][ELF] Add support for st_value and st_size. After this patch, the ELF file produced by `yaml2obj-elf-symbol-basic.yaml`, when linked and executed on x86_64 (under SysV ABI, obviously; I tested on Linux), produces a working executable that goes into an infinite loop! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184469 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 7 years ago
4 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5757 ELF_STB Binding;
5858 ELF_STT Type;
5959 StringRef Section;
60 llvm::yaml::Hex64 Value;
61 llvm::yaml::Hex64 Size;
6062 };
6163 struct Section {
6264 StringRef Name;
315315 IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
316316 IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
317317 IO.mapOptional("Section", Symbol.Section, StringRef());
318 IO.mapOptional("Value", Symbol.Value, Hex64(0));
319 IO.mapOptional("Size", Symbol.Size, Hex64(0));
318320 }
319321
320322 void MappingTraits::mapping(IO &IO,
0 # RUN: yaml2obj -format=elf %s | llvm-readobj -symbols - | FileCheck %s
1 # RUN: yaml2obj -format=elf %s | llvm-objdump -d -no-show-raw-insn - | FileCheck %s --check-prefix=DISASSEMBLY
12 !ELF
23 FileHeader:
34 Class: ELFCLASS64
89 - Name: .text
910 Type: SHT_PROGBITS
1011 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
12 Content: "90EBFE" # x86 machine code
13 # NOP ; To make main's `Value` non-zero (for testing).
14 # main:
15 # JMP -2 ; (infloop)
16 # This YAML file is a valid relocatable object that,
17 # when linked and run on x86_64, will go into an
18 # infloop.
1119 - Name: .symtab
1220 Type: SHT_SYMTAB
1321 Symbols:
1523 Binding: STB_GLOBAL
1624 Type: STT_FUNC
1725 Section: .text
26 Value: 0x1
27 Size: 2
1828
1929 # CHECK: Symbols [
2030 # CHECK-NEXT: Symbol {
2131 # CHECK-NEXT: Name: (0)
2232 # CHECK: Symbol {
2333 # CHECK-NEXT: Name: main
34 # CHECK-NEXT: Value: 0x1
35 # CHECK-NEXT: Size: 2
2436 # CHECK: Binding: Global
2537 # CHECK-NEXT: Type: Function
2638 # CHECK: Section: .text
39
40 # DISASSEMBLY: Disassembly of section .text:
41 # DISASSEMBLY-NEXT: main:
42 # DISASSEMBLY-NEXT: 1: jmp -2
205205 exit(1);
206206 }
207207 Symbol.st_shndx = Index;
208 Symbol.st_value = Sym.Value;
209 Symbol.st_size = Sym.Size;
208210 Syms.push_back(Symbol);
209211 }
210212