[PATCH] D18317: [ELF] - Don't create PT_LOAD's when linking script is used.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 08:14:25 PDT 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.

Actually patch is more about that we should not align the PT_LOAD's created
if we use linker script. That is the main aim of this patch.
(we dont want to touch the location counter when we use script)

I don't have strong opinion about creating PT_LOAD's as ld and gold do diffterent things that
both looks ok for me.
Please see below:

Consider the next code and empty linker script file..
main.s:

```
.globl _start;
_start:
nop

.section .data
.quad 0
```

llvm-mc -filetype=obj -triple=x86_64-pc-linux main.s -o main.o
gold main.o -script empty.script -o test

produces 2 Loads without allignment of VA's:
```
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x00000000000000b1 0x00000000000000b1  R E    1000
  LOAD           0x00000000000000b1 0x00000000004010b1 0x00000000004010b1
                 0x0000000000000008 0x0000000000000008  RW     1000

```
GNU ld has another output here:
ld main.o -script empty.script -o test
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000200000 0x0000000000000000 0x0000000000000000
                 0x0000000000000009 0x0000000000000009  RWE    200000

So there is a single PT_LOAD with flags combined. 

This patch implements the same behavior as ld do.

http://reviews.llvm.org/D18317

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/Writer.cpp
  test/ELF/end.s
  test/ELF/linkerscript-oneload.s
  test/ELF/linkerscript-sections-keep.s
  test/ELF/linkerscript-sections-padding.s
  test/ELF/wildcards.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18317.51164.patch
Type: text/x-patch
Size: 11949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160321/0e67e1ce/attachment.bin>


More information about the llvm-commits mailing list