[lld] r309829 - [ELF] When the code segment is the last, align it to the page boundary

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 16:18:30 PDT 2017


Joerg Sonnenberger via llvm-commits <llvm-commits at lists.llvm.org>
writes:

> As I wrote on Phabricator, I don't find this behavior that desirable. It
> will waste on average 2KB per binary or more, that easily sums up. The commit
> message is also misleading, it doesn't align so much as it does add
> padding.

The new behavior is in line with how we handle other PT_LOADs. For
example, given

	.section	.text,"ax", at progbits
	nop
	.section	.data,"aw", at progbits
	.long	42
	.section	.rodata,"a", at progbits
	.long	42

before and after this change we will create a .so with .text at 0x1000,
.data at 0x2000 and 0x3000.

This change only has an impact if the rx was the last alloc section.

bfd and gold have an optimization where they overlap PT_LOADs on
disk. The flip side is that some data can show up in executable memory.

We should implement that optimization at some point (I would suggest
once thunks is done), but we should probably keep executable PT_LOADs no
overlapping by default.

Cheers,
Rafael


More information about the llvm-commits mailing list