ld ALIGN() function does not match documentation

Bug #1471226 reported by Andreas Fritiofson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Undecided
Unassigned

Bug Description

According to the documentation ( https://sourceware.org/binutils/docs/ld/Builtin-Functions.html ): "The two operand ALIGN allows an arbitrary expression to be aligned upwards (ALIGN(align) is equivalent to ALIGN(., align))". However the following test case does not show the same behaviour of the two forms. If they really were equivalent, the symbols test1, test2 and test3 would have the same value below. It appears the second form aligns the section-relative address, while the first for aligns the absolute address.

$ echo > test.c

$ cat test.ld
align = 0x100;

SECTIONS
{
    .section_with_unaligned_end : {
        . += 0x1234;
    }
    .test :
    {
 . += 0xabcd;
        . = ALIGN(align);
 test1 = .;
 . = ALIGN(align);
 test2 = .;
 . = ALIGN(., align);
 test3 = .;
    }
    /DISCARD/ : { *(*) }
}

$ arm-none-eabi-gcc test.c -T test.ld

$ arm-none-eabi-nm a.out | grep test
0000bf00 B test1
0000bf00 B test2
0000bf34 B test3

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Hi Andreas,

I agree with you that this behavior is not the expected one after reading the documentation. I wrote up a bug report and sent it upstream. Hopefully they will be able to enlighten us on whether this is somehow intended behavior, which in my opinion would require a change to the documentation at the very least, or if it is a bug.

See https://sourceware.org/ml/binutils/2015-07/msg00045.html

Kind Regards,
Andre

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Hi Andreas,

After some upstream discussions and patches, I think they have eventually settled for changing the documentation.

See https://sourceware.org/ml/binutils/2015-08/msg00030.html

Hopefully that works for you!

Changed in gcc-arm-embedded:
status: New → In Progress
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

The documentation in our 2016Q2 release now mentions: "ALIGN(align ) is equivalent to
ALIGN(ABSOLUTE(.), align )". Marking this bug as fix release

Changed in gcc-arm-embedded:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers