Skip to content

linkerscript SUBALIGN applies to each input section #343

@quic-seaswara

Description

@quic-seaswara

SUBALIGN may be used to adjust the alignment of each input section

cat > script.t << '!'
SECTIONS {
  text (0x14) : SUBALIGN(64) {
    *(.text*)
  }
}
!

cat > test.c << '!'
int foo() { return 1; }
int bar() { return 0; }
!

clang -falign-functions=4 --target=riscv32-unknown-elf -c test.c -ffunction-sections
ld.eld test.o -T script.t -Map map.txt -o eld.out

Bug

$ llvm-readelf -s eld.out | grep -E 'foo|bar'
     9: 00000014    18 FUNC    GLOBAL DEFAULT     1 foo
    10: 00000028    18 FUNC    GLOBAL DEFAULT     1 bar

Correct Behavior

$ llvm-readelf -s bfd.out | grep -E 'foo|bar'
     9: 00000040    18 FUNC    GLOBAL DEFAULT     1 foo
    10: 00000080    18 FUNC    GLOBAL DEFAULT     1 bar

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions