From f4646a0bb103f7ad33cf464d088d05cf83851f6d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 15 Mar 2019 03:20:13 +0000 Subject: [PATCH] [ELF] Fix 3 tests after D56828 arm-plt-reloc.s arm-thumb-plt-reloc.s: update offset calculations pack-dyn-relocs-loop.s: this test is very sensitive to exact section offsets and sizes. If we comment out the following two lines in SyntheticSections.cpp, we should reproduce `ld.lld: error: thunk creation not converged` caused by oscillation of the section size. if (RelocData.size() < OldSize) RelocData.append(OldSize - RelocData.size(), 0); Use -z norelro to counteract the layout change (to be more specific, we have to place .dynamic below .foo so that offset(foo) remains 0x10004) llvm-svn: 356229 --- lld/test/ELF/arm-plt-reloc.s | 8 ++++---- lld/test/ELF/arm-thumb-plt-reloc.s | 8 ++++---- lld/test/ELF/pack-dyn-relocs-loop.s | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lld/test/ELF/arm-plt-reloc.s b/lld/test/ELF/arm-plt-reloc.s index 910cd8750abe..87d7ca6b62bf 100644 --- a/lld/test/ELF/arm-plt-reloc.s +++ b/lld/test/ELF/arm-plt-reloc.s @@ -50,7 +50,7 @@ _start: // DSO-NEXT: Disassembly of section .plt: // DSO-NEXT: $a: // DSO-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! -// (0x1024 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfdc) = 0x2008 = .got.plt[3] +// (0x1024 + 8) + (0 RoR 12) + 4096 + (0xfdc) = 0x3008 = .got.plt[3] // DSO-NEXT: 1024: 00 e6 8f e2 add lr, pc, #0, #12 // DSO-NEXT: 1028: 01 ea 8e e2 add lr, lr, #4096 // DSO-NEXT: 102c: dc ff be e5 ldr pc, [lr, #4060]! @@ -60,21 +60,21 @@ _start: // DSO-NEXT: 1038: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO-NEXT: 103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// (0x1040 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfc4) = 0x200c +// (0x1040 + 8) + (0 RoR 12) + 4096 + (0xfc4) = 0x300c // DSO-NEXT: 1040: 00 c6 8f e2 add r12, pc, #0, #12 // DSO-NEXT: 1044: 01 ca 8c e2 add r12, r12, #4096 // DSO-NEXT: 1048: c4 ff bc e5 ldr pc, [r12, #4036]! // DSO: $d: // DSO-NEXT: 104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// (0x1050 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfb8) = 0x2010 +// (0x1050 + 8) + (0 RoR 12) + 4096 + (0xfb8) = 0x3010 // DSO-NEXT: 1050: 00 c6 8f e2 add r12, pc, #0, #12 // DSO-NEXT: 1054: 01 ca 8c e2 add r12, r12, #4096 // DSO-NEXT: 1058: b8 ff bc e5 ldr pc, [r12, #4024]! // DSO: $d: // DSO-NEXT: 105c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// (0x1060 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfac) = 0x2014 +// (0x1060 + 8) + (0 RoR 12) + 4096 + (0xfac) = 0x3014 // DSO-NEXT: 1060: 00 c6 8f e2 add r12, pc, #0, #12 // DSO-NEXT: 1064: 01 ca 8c e2 add r12, r12, #4096 // DSO-NEXT: 1068: ac ff bc e5 ldr pc, [r12, #4012]! diff --git a/lld/test/ELF/arm-thumb-plt-reloc.s b/lld/test/ELF/arm-thumb-plt-reloc.s index c66fbca000f0..10973e82f548 100644 --- a/lld/test/ELF/arm-thumb-plt-reloc.s +++ b/lld/test/ELF/arm-thumb-plt-reloc.s @@ -60,7 +60,7 @@ _start: // DSOARM: Disassembly of section .plt: // DSOARM-NEXT: $a: // DSOARM-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! -// (0x1024 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfdc) = 0x2008 = .got.plt[3] +// (0x1024 + 8) + (0 RoR 12) + 4096 + (0xfdc) = 0x3008 = .got.plt[3] // DSOARM-NEXT: 1024: 00 e6 8f e2 add lr, pc, #0, #12 // DSOARM-NEXT: 1028: 01 ea 8e e2 add lr, lr, #4096 // DSOARM-NEXT: 102c: dc ff be e5 ldr pc, [lr, #4060]! @@ -71,21 +71,21 @@ _start: // DSOARM-NEXT: 1038: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM-NEXT: 103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// (0x1040 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfc4) = 0x200c +// (0x1040 + 8) + (0 RoR 12) + 4096 + (0xfc4) = 0x300c // DSOARM-NEXT: 1040: 00 c6 8f e2 add r12, pc, #0, #12 // DSOARM-NEXT: 1044: 01 ca 8c e2 add r12, r12, #4096 // DSOARM-NEXT: 1048: c4 ff bc e5 ldr pc, [r12, #4036]! // DSOARM: $d: // DSOARM-NEXT: 104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// (0x1050 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfb8) = 0x2010 +// (0x1050 + 8) + (0 RoR 12) + 4096 + (0xfb8) = 0x3010 // DSOARM-NEXT: 1050: 00 c6 8f e2 add r12, pc, #0, #12 // DSOARM-NEXT: 1054: 01 ca 8c e2 add r12, r12, #4096 // DSOARM-NEXT: 1058: b8 ff bc e5 ldr pc, [r12, #4024]! // DSOARM: $d: // DSOARM-NEXT: 105c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// (0x1060 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfac) = 0x2014 +// (0x1060 + 8) + (0 RoR 12) + 4096 + (0xfac) = 0x3014 // DSOARM-NEXT: 1060: 00 c6 8f e2 add r12, pc, #0, #12 // DSOARM-NEXT: 1064: 01 ca 8c e2 add r12, r12, #4096 // DSOARM-NEXT: 1068: ac ff bc e5 ldr pc, [r12, #4012]! diff --git a/lld/test/ELF/pack-dyn-relocs-loop.s b/lld/test/ELF/pack-dyn-relocs-loop.s index 9d71eae05a00..ca0305627969 100644 --- a/lld/test/ELF/pack-dyn-relocs-loop.s +++ b/lld/test/ELF/pack-dyn-relocs-loop.s @@ -1,7 +1,7 @@ // REQUIRES: arm, aarch64 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-android %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t.so --pack-dyn-relocs=android +// RUN: ld.lld -shared %t.o -o %t.so --pack-dyn-relocs=android -z norelro // RUN: llvm-readobj -s %t.so | FileCheck %s // This test is making sure the Android packed relocation support doesn't @@ -16,36 +16,36 @@ // CHECK-NEXT: Flags [ (0x2) // CHECK-NEXT: SHF_ALLOC (0x2) // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x248 -// CHECK-NEXT: Offset: 0x248 -// CHECK-NEXT: Size: 22 +// CHECK-NEXT: Address: 0x1D8 +// CHECK-NEXT: Offset: 0x1D8 +// CHECK-NEXT: Size: 21 // CHECK: Name: x (43) // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x2) // CHECK-NEXT: SHF_ALLOC (0x2) // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x25E -// CHECK-NEXT: Offset: 0x25E -// CHECK-NEXT: Size: 64980 +// CHECK-NEXT: Address: 0x1ED +// CHECK-NEXT: Offset: 0x1ED +// CHECK-NEXT: Size: 65036 // CHECK: Name: barr (45) // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x2) // CHECK-NEXT: SHF_ALLOC (0x2) // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x10032 -// CHECK-NEXT: Offset: 0x10032 +// CHECK-NEXT: Address: 0xFFFA +// CHECK-NEXT: Offset: 0xFFFA // CHECK-NEXT: Size: 0 -// CHECK: Name: foo (71) +// CHECK: Name: foo (62) // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x3) // CHECK-NEXT: SHF_ALLOC (0x2) // CHECK-NEXT: SHF_WRITE (0x1) // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x30004 -// CHECK-NEXT: Offset: 0x30004 +// CHECK-NEXT: Address: 0x10004 +// CHECK-NEXT: Offset: 0x10004 // CHECK-NEXT: Size: 12 @@ -59,7 +59,7 @@ foof: .long bar .section x,"a" -.zero 64980 +.zero 65036 .section barr,"a" .p2align 1