diff options
author | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-05-13 19:34:37 +0000 |
---|---|---|
committer | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-05-13 19:34:37 +0000 |
commit | 240b9b6078cdf8048945107b4ff7d517729dab96 (patch) | |
tree | 46ede5378ba9cddb219e4af0b52b71ffbcc4e637 /test | |
parent | a753ff72b2dfcd9c09451a124373e0a8ed1a1d47 (diff) | |
download | external_llvm-240b9b6078cdf8048945107b4ff7d517729dab96.zip external_llvm-240b9b6078cdf8048945107b4ff7d517729dab96.tar.gz external_llvm-240b9b6078cdf8048945107b4ff7d517729dab96.tar.bz2 |
PPC64: Constant initializers with dynamic relocations go in .data.rel.ro.
This fixes warning messages observed in the oggenc application test in
projects/test-suite. Special handling is needed for the 64-bit
PowerPC SVR4 ABI when a constant is initialized with a pointer to a
function in a shared library. Because a function address is
implemented as the address of a function descriptor, the use of copy
relocations can lead to problems with initialization. GNU ld
therefore replaces copy relocations with dynamic relocations to be
resolved by the dynamic linker. This means the constant cannot reside
in the read-only data section, but instead belongs in .data.rel.ro,
which is designed for constants containing dynamic relocations.
The implementation creates a class PPC64LinuxTargetObjectFile
inheriting from TargetLoweringObjectFileELF, which behaves like its
parent except to place constants of this sort into .data.rel.ro.
The test case is reduced from the oggenc application.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/PowerPC/addrfuncstr.ll | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/addrfuncstr.ll b/test/CodeGen/PowerPC/addrfuncstr.ll new file mode 100644 index 0000000..60c02d4 --- /dev/null +++ b/test/CodeGen/PowerPC/addrfuncstr.ll @@ -0,0 +1,27 @@ +; RUN: llc -O0 < %s | FileCheck %s + +; Verify that a constant with an initializer that may turn into a dynamic +; relocation is not placed in .rodata, but rather in .data.rel.ro. + +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64" +target triple = "powerpc64-unknown-linux-gnu" + +%struct.x = type { i64 (i8*, i64, i64, %struct._IO_FILE*)* } +%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] } +%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } + +@_ZL1y = internal constant %struct.x { i64 (i8*, i64, i64, %struct._IO_FILE*)* @fread }, align 8 + +; Function Attrs: nounwind +define %struct.x* @_Z3foov() #0 { +entry: + ret %struct.x* @_ZL1y +} + +declare i64 @fread(i8*, i64, i64, %struct._IO_FILE*) #1 + +; CHECK: .section .data.rel.ro +; CHECK: .quad fread + +attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } |