https://reviews.llvm.org/D150510 places .lrodata before .rodata to minimize the number of permission transitions in the memory image. However, this layout is less ideal for -fno-pic code (which is still important). Small code model -fno-pic code has R_X86_64_32S relocations with a range of `[0,2**31)` (if we ignore the negative area). Placing `.lrodata` earlier exerts relocation pressure on such code. Non-x86 64-bit architectures generally have a similar `[0,2**31)` limitation if they don't use PC-relative relocations. If we place .lrodata later, we will need one extra PT_LOAD. Two layouts are appealing: * .bss/.lbss/.lrodata/.ldata (GNU ld) * .bss/.ldata/.lbss/.lrodata The GNU ld layout has the nice property that there is only one BSS (except .tbss/.relro_padding). Add -z lrodata-after-bss to support this layout. Since a read-only PT_LOAD segment (for large data sections) may appear after RW PT_LOAD segments. The placement of `_etext` has to be adjusted. Pull Request: https://github.com/llvm/llvm-project/pull/81224
21 lines
665 B
LLVM
21 lines
665 B
LLVM
; REQUIRES: x86
|
|
; RUN: llvm-as %s -o %t.o
|
|
; RUN: ld.lld %t.o -o %ts -mllvm -code-model=small
|
|
; RUN: ld.lld %t.o -o %tl -mllvm -code-model=large
|
|
; RUN: llvm-objdump -d %ts | FileCheck %s --check-prefix=CHECK-SMALL
|
|
; RUN: llvm-objdump -d %tl | FileCheck %s --check-prefix=CHECK-LARGE
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
@data = internal constant [0 x i32] []
|
|
|
|
define ptr @_start() nounwind readonly {
|
|
entry:
|
|
; CHECK-SMALL-LABEL: <_start>:
|
|
; CHECK-SMALL: movl ${{.*}}, %eax
|
|
; CHECK-LARGE-LABEL: <_start>:
|
|
; CHECK-LARGE: movabsq ${{.*}}, %rax
|
|
ret ptr @data
|
|
}
|