1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/test/tools/yaml2obj/relocation-missing-symbol.yaml
James Henderson 9af6a3c5cb [yaml2obj]Allow explicit symbol indexes in relocations and emit error for bad names
Prior to this change, the "Symbol" field of a relocation would always be
assumed to be a symbol name, and if no such symbol existed, the
relocation would reference index 0. This confused me when I tried to use
a literal symbol index in the field: since "0x1" was not a known symbol
name, the symbol index was set as 0. This change falls back to treating
unknown symbol names as integers, and emits an error if the name is not
found and the string is not an integer.

Note that the Symbol field is optional, so if a relocation doesn't
reference a symbol, it shouldn't be specified. The new error required a
number of test updates.

Reviewed by: grimar, ruiu
Differential Revision: https://reviews.llvm.org/D58510

llvm-svn: 355938
2019-03-12 17:00:25 +00:00

25 lines
554 B
YAML

# Show that yaml2obj rejects a symbol reference from a relocation if the symbol
# does not exist.
# RUN: not yaml2obj %s -o %t 2>&1 | FileCheck %s
# CHECK: Unknown symbol referenced: 'does_not_exist' at YAML section '.rela.text'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .rela.text
Type: SHT_RELA
Info: .text
Link: .symtab
Relocations:
- Type: R_X86_64_PC32
Offset: 0
Symbol: does_not_exist