[PATCH] D23063: [ELF] - Linkerscript: implemented SUBALIGN() command.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 07:20:59 PDT 2016


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

You can force input section alignment within an output section by using SUBALIGN. The
value specified overrides any alignment given by input sections, whether larger or smaller.

SUBALIGN is used in many projects in the wild, for example:
  https://github.com/kubo39/tinycr/blob/536a8a0ba290b08659d347a0bdddb966cff44441/script.ld
  https://github.com/def-/nim-small-coreutils/blob/3cb5e99ab8435220c82b9c307ce8909841655cc8/tools/x86_64/script.ld
  https://github.com/takeneco/uniqos/blob/57e802d54979f1f02942e0260687c417e46c58df/arch/x86_64/boot/fd/bootsect/bootsect.ld
  https://github.com/sjrct/Frosk/blob/13ee75a64ae98c652c32795bcc5d17ae459d2cfc/kernel/kernel.ld
and many others.

Patch implements it with a single restriction: access to location counter in expression is forbidden. That should not be a problem
as every script I saw uses just integer value here. And the reasons of that is that we assign offsets before we know VA of section,
so we do not know the location counter value. Solution would be to layout input sections right before assign address to output section I guess,
but as I mentioned before that does not seems reasonable to implement for this command.

https://reviews.llvm.org/D23063

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/OutputSections.cpp
  test/ELF/linkerscript/linkerscript-subalign.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23063.66472.patch
Type: text/x-patch
Size: 10741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/cd413eb8/attachment.bin>


More information about the llvm-commits mailing list