This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF][ARM] Implement support for Tag_ABI_VFP_args
ClosedPublic

Authored by peter.smith on Jul 30 2018, 9:18 AM.

Details

Summary

The Tag_ABI_VFP_args build attribute controls the procedure call standard used for floating point parameters on ARM. The values are:

0 - Base AAPCS (FP Parameters passed in Core (Integer) registers
1 - VFP AAPCS (FP Parameters passed in FP registers)
2 - Toolchain specific (Neither Base or VFP)
3 - Compatible with all (No use of floating point parameters)

If the Tag_ABI_VFP_args build attribute is missing it has an implicit value of 0.

We use the attribute in two ways:

  • Detect a clash in calling convention between Base, VFP and Toolchain. We follow ld.bfd's lead and do not error if there is a clash between an implicit Base AAPCS caused by a missing attribute. Many projects including the hard-float (VFP AAPCS) version of glibc contain assembler files that do not use floating point but do not have Tag_ABI_VFP_args.
  • Set the EF_ARM_ABI_FLOAT_SOFT or EF_ARM_ABI_FLOAT_HARD ELF header flag for Base or VFP AAPCS respectively. This flag is used by some ELF loaders.

The patch is based on the patch posted by Mark Kettenis to llvm-dev http://lists.llvm.org/pipermail/llvm-dev/2018-July/124876.html . It is dependent on D49992 to add the EF_ARM_ABI_FLOAT_SOFT and EF_ARM_ABI_FLOAT_HARD ELF header flags.

References:

Fixes PR36009 (https://bugs.llvm.org/show_bug.cgi?id=36009)

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

peter.smith created this revision.Jul 30 2018, 9:18 AM
kettenis accepted this revision.Jul 30 2018, 11:06 AM

LGTM

Nothing significant from my original diff survives, so as far as copyright is concerned, this can totally be considered to be Peter's work.

This revision is now accepted and ready to land.Jul 30 2018, 11:06 AM
ruiu added a comment.Jul 30 2018, 11:26 AM

Overall looking good.

ELF/InputFiles.cpp
497

I'd start this comment with "This is ARM only" to make it clear that this is ARM only.

512

nit: since you are using this local variable only once, you can inline it.

519

If we don't have an enum variable for this magic variable, should we add that one to LLVM?

Looks good to me too. Minor comments below.

ELF/InputFiles.cpp
501

You do not need the namespace name here (elf::) I think.

520

toolchain -> Toolchain

526

Should default (it's unknown, right?) value trigger an error/warning/unreachable instead of return?

test/ELF/Inputs/arm-vfp-arg-base.s
12

I would add a comment, just like in other inputs you have.

Thanks all for the comments.

I've updated the patch with as many of the review comments addressed as possible:

  • D50049 raised to add the missing enum values for Tag_ABI_VFP_args
  • I've made it an error if the Tag_ABI_VFP_args contains an out of range value (I've now used VFPArgs twice so I've not inlined it). I've added a test to check we catch the illegal value.
  • Comments altered according to suggestions.
grimar accepted this revision.Jul 31 2018, 4:25 AM

LGTM

This revision was automatically updated to reflect the committed changes.