Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that Elf_Rel addends are always written for dynamic relocations
Summary: This follows up on r321889 where writing of Elf_Rel addends was partially moved to RelocationBaseSection. This patch ensures that the addends are always written to the output section when a input section uses RELA but the output is REL. Differential Revision: https://reviews.llvm.org/D42843 llvm-svn: 325328
- Loading branch information
1 parent
995ba6e
commit cfb6093
Showing
7 changed files
with
62 additions
and
7 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
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
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
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 @@ | ||
# REQUIRES: mips | ||
# Check that we correctly write addends if the output use Elf_Rel but the input | ||
# uses Elf_Rela | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t-rela.o | ||
# RUN: llvm-readobj -h -s -section-data -relocations %t-rela.o | FileCheck -check-prefix INPUT-RELA %s | ||
# INPUT-RELA: ElfHeader { | ||
# INPUT-RELA: Class: 64-bit | ||
# INPUT-RELA: DataEncoding: BigEndian | ||
# INPUT-RELA: Section { | ||
# INPUT-RELA: Name: .data | ||
# INPUT-RELA: SectionData ( | ||
# INPUT-RELA-NEXT: 0000: 00000000 00000000 ABCDEF00 12345678 |.............4Vx| | ||
# ^--- No addend here since it uses RELA | ||
# INPUT-RELA: Relocations [ | ||
# INPUT-RELA-NEXT: Section ({{.+}}) .rela.data { | ||
# INPUT-RELA-NEXT: 0x0 R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE foo 0x5544 | ||
# INPUT-RELA-NEXT: } | ||
# INPUT-RELA-NEXT: ] | ||
|
||
# Previously the addend to the dynamic relocation in the .data section was not copied if | ||
# the input file used RELA and the output uses REL. Check that it works now: | ||
# RUN: ld.lld -shared -o %t.so %t-rela.o -verbose | ||
# RUN: llvm-readobj -h -s -section-data -relocations %t.so | FileCheck -check-prefix RELA-TO-REL %s | ||
# RELA-TO-REL: ElfHeader { | ||
# RELA-TO-REL: Class: 64-bit | ||
# RELA-TO-REL: DataEncoding: BigEndian | ||
# RELA-TO-REL: Section { | ||
# RELA-TO-REL: Name: .data | ||
# RELA-TO-REL: SectionData ( | ||
# RELA-TO-REL-NEXT: 0000: 00000000 00005544 ABCDEF00 12345678 |......UD.....4Vx| | ||
# ^--- Addend for relocation in .rel.dyn | ||
# RELA-TO-REL: Relocations [ | ||
# RELA-TO-REL-NEXT: Section ({{.+}}) .rel.dyn { | ||
# RELA-TO-REL-NEXT: 0x10000 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE foo 0x0 | ||
# RELA-TO-REL-NEXT: } | ||
# RELA-TO-REL-NEXT: ] | ||
|
||
.extern foo | ||
|
||
.data | ||
.quad foo + 0x5544 | ||
.quad 0xabcdef0012345678 |