mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
18bbb959e4
The ELF specification says that all ELF data structures are aligned to their natural alignments both in memory and file. That means when we access mmap'ed ELF files, we could assume that all data structures are aligned properly. However, in reality, we assume that the data structures are aligned only to two bytes because .a files only guarantee that their member files are aligned to two bytes in archive files. So the data access is already unaligned. This patch relaxes the alignment requirement even more, so that we accept unaligned access to all ELF data structures. This patch in particular makes lld bug-compatible with icc. Intel C compiler doesn't seem to care about data alignment and generates unaligned relocation sections (https://bugs.llvm.org/show_bug.cgi?id=35854). I also saw another instance of compatibility issues with our internal tool which creates unaligned section headers. Because GNU linkers are not picky about alignment, looks like it is not uncommon that ELF-generating tools create unaligned files. There is a performance penalty with this patch on host machines on which unaligned access is expensive. x86 and AArch64 are fine. ARMv6 is a problem, but I don't think using ARMv6 machines as hosts is common, so I believe it's not a real problem. Differential Revision: https://reviews.llvm.org/D41978 llvm-svn: 322407
30 lines
741 B
Plaintext
30 lines
741 B
Plaintext
# RUN: yaml2obj %s -o %t.o
|
|
# RUN: llvm-readobj -r %t.o 2>&1 | FileCheck %s
|
|
|
|
# CHECK: Format: ELF64-x86-64
|
|
# CHECK-NEXT: Arch: x86_64
|
|
# CHECK-NEXT: AddressSize: 64bit
|
|
# CHECK-NEXT: LoadName:
|
|
# CHECK-NEXT: Relocations [
|
|
# CHECK-NEXT: Section (2) .rela.foo {
|
|
# CHECK-NEXT: 0x0 R_X86_64_NONE - 0x0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .foo
|
|
Type: SHT_PROGBITS
|
|
Content: 42
|
|
- Name: .rela.foo
|
|
Type: SHT_RELA
|
|
Info: .foo
|
|
Relocations:
|
|
- Offset: 0
|
|
Type: R_X86_64_NONE
|