-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] - Do not segfault when using -r and section groups.
If we had SHT_GROUP sections, then when -r was used we might crash. This is PR31952. Issue happened because we emited relocation section though its target was discared because was a member of duplicated group. When we tried to get VA of target, segfault happened. Core cause is the bug that GNU as 2.27 (and probably later versions) has. In compare with llvm-mc, it does not include relocation sections into the group, like shown in testcase. This patch covers that case. Differential revision: https://reviews.llvm.org/D29929 llvm-svn: 295067
- Loading branch information
George Rimar
committed
Feb 14, 2017
1 parent
6dedf65
commit ee6f22c
Showing
2 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# RUN: yaml2obj %s -o %t.o | ||
# RUN: ld.lld %t.o %t.o -o %t -r | ||
# RUN: llvm-readobj -s %t.o | FileCheck %s | ||
|
||
# CHECK: Name: .text.foo | ||
# CHECK: Name: .rela.text.foo | ||
|
||
## YAML below corresponds to following asm code: | ||
## .section .text,"axG",@progbits,foo,comdat | ||
## .quad bar | ||
## gas 2.27 does not include .rela.text to group in that case: | ||
## COMDAT group section [ 1] `.group' [foo] contains 1 sections: | ||
## [Index] Name | ||
## [ 5] .text | ||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .group | ||
Type: SHT_GROUP | ||
Link: .symtab | ||
Info: foo | ||
Members: | ||
- SectionOrType: GRP_COMDAT | ||
- SectionOrType: .text.foo | ||
- Name: .text.foo | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] | ||
- Name: .rela.text.foo | ||
Type: SHT_RELA | ||
Flags: [ SHF_INFO_LINK ] | ||
Link: .symtab | ||
Info: .text.foo | ||
Relocations: | ||
- Offset: 0x0000000000000000 | ||
Symbol: foo | ||
Type: R_X86_64_64 | ||
Symbols: | ||
Global: | ||
- Name: foo |