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.