[PATCH] D37998: Tweak orphan section placement

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 16:13:44 PDT 2017


Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu added a comment.
>
> I'm not sure if I understand this patch correctly.
>
>   .some_sec { ...} ;
>   __stack_start = .;
>   . = . + 0x2000;
>   __stack_end = .;
>
> I think I agree that .comment shouldn't be before __stack_end, but what if it is not a .comment? For example, if an orphan section is a RO section, it might make sense to handle it with the normal rule.

With this patch we still have the normal rule to find where we put a
section relative to other sections (getRankProximity). If that function
decides that the orphan should go before .some_sec, it will be placed
there just like we used to.

The only thing that is changed is the position relative to non section
commands. If the orphan section is placed last, we now put it after any
non section commands that follow the second last section.

This has the nice property of not interfering with a linker script if it
covers only the start of the file. The issue was found with a script not
specifying how to layout non alloc sections, but would also apply to a
script that covered only ro/rx sections for example.

Cheers,
Rafael


More information about the llvm-commits mailing list