This is an archive of the discontinued LLVM Phabricator instance.

[lld][ELF] Don't apply --fix-cortex-a53-843419 to relocatable links.
ClosedPublic

Authored by efriedma on Jan 17 2020, 4:42 PM.

Details

Summary

The code doesn't apply the fix correctly to relocatable links. I could try to fix the code that applies the fix, but it's pointless: we don't actually know what the offset will be in the final executable. So just ignore the flag for relocatable links.

Issue discovered building Android.

Diff Detail

Event Timeline

efriedma created this revision.Jan 17 2020, 4:42 PM
Herald added a project: Restricted Project. · View Herald Transcript

Can you check with GNU ld, if --fix-cortex-a53-843419 is ignored when -r is specified?

peter.smith accepted this revision.Jan 20 2020, 12:09 PM

Reading the BFD source it looks like stubs (which is what errata patches like this are generated) are not added for relocatable links, I couldn't find any ld tests for them and an empirical test with:

        .section .text, "ax", %progbits
        .balign 4096
        .globl t3_ff8_ldr
        .type t3_ff8_ldr, %function
        .space 4096 - 8
t3_ff8_ldr:
        adrp x0, dat1
        ldr x1, [x1, #0]
        ldr x0, [x0, :lo12:dat1]
        ret

        .data
dat1:   .quad 1

ld.bfd will patch with a normal link and -fix-cortex-a53-843419 but will not when I add the -r.

It would be possible to make a pessimistic fix that would work during ld -r, essentially assume the worst for anything you didn't know and overalign the section to ensure the resulting alignment. However I don't think it would be practically useful due to the amount of disruption.

This same argument applies to the fix-cortex-a8 option, but that can be done in a separate patch; my fault so I'll hopefully get the time to do this tomorrow and if not, then this week.

This revision is now accepted and ready to land.Jan 20 2020, 12:09 PM
MaskRay accepted this revision.Jan 20 2020, 12:36 PM
This revision was automatically updated to reflect the committed changes.