brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · dfddf18 Raw
47 lines · plain
1// Check that we are able to rewrite binaries when we fail to identify a2// suitable location to put new code and user supplies a custom one via3// --custom-allocation-vma. This happens more obviously if the binary has4// segments mapped to very high addresses.5 6// In this example, my.reserved.section is mapped to a segment to be loaded7// at address 0x10000000000, while regular text should be at 0x200000. We8// pick a vma in the middle at 0x700000 to carve space for BOLT to put data,9// since BOLT's usual route of allocating after the last segment will put10// code far away and that will blow up relocations from main.11 12// RUN: split-file %s %t13// RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o14// RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-T %t/main.ls15// RUN: llvm-bolt %t.exe -o %t.bolt --custom-allocation-vma=0x70000016 17//--- main.s18  .type            reserved_space,@object19  .section        .my.reserved.section,"awx",@nobits20  .globl           reserved_space21  .p2align         4, 0x022reserved_space:23  .zero  0x8000000024  .size   reserved_space, 0x8000000025 26	.text27  .globl main28  .globl _start29  .type main, %function30_start:31main:32	.cfi_startproc33  nop34  nop35  nop36  retq37	.cfi_endproc38.size main, .-main39 40//--- main.ls41SECTIONS42{43    .my.reserved.section 1<<40 : {44      *(.my.reserved.section);45    }46} INSERT BEFORE .comment;47