Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hi, According to the GNU LD documentation: <<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.>> However, let's consider the behaviour of GNU ld Suppose we have the following test: $ cat one.c char a_one __attribute__((__aligned__(8))) __attribute__((section(".mysection"))) = 0; and the following linker script: $ cat foo.lds SECTIONS { . = 0x10024; .mysection : SUBALIGN(4) { *(.mysection) } .note.gnu.property ALIGN(8) : { *(.note.gnu.property) *(.comment) } } We suppose that the section .mysection would be aligned by 4 despite of alignment attribute 8 in source code. However, after linking object file "one.o" __ with gnu ld linker the symbol .mysection is aligned by 8 $ gcc -c one.c $ ld -T foo.lds one.o -o foo.out $ objdump -h foo.out foo2.out: file format elf64-x86-64Sections: Idx Name Size VMA LMA File off Algn 0 .mysection 00000001 0000000000010028 0000000000010028 00001028 2**3 CONTENTS, ALLOC, LOAD, DATA 1 .note.gnu.property 0000004b 0000000000010030 0000000000010030 00001030 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA It seems like this is contrary to documented behavior. Below you can see the patch fixed this problem.
- Loading branch information