[PATCH] generate .init_array instead of .ctors sections for AArch64 ELF targets
kristof.beyls at arm.com
Thu Jan 9 08:40:40 PST 2014
The .init_array should be used on any platform that follows the AArch64
C++ ABI, which I think would be any platform using ELF as an object file
format. I think that the patch does implement that (but this is an area
of the code I'm not very familiar with).
As for factoring out defaulting -fuse-init-array: the decision logic
for Linux::addClangTargetOptions and Generic_GCC:addClangTargetOptions
is different, so the only thing to factor out would be
+ if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
The conditions on when to add this by default would remain different
between Generic_GCC and Linux, and therefore the 2 implementations of
addClangTargetOptions in the Generic_GCC and Linux subclasses need to
bool UseInitArrayDefault = getTriple().getArch() == llvm::Triple::aarch64;
const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
bool UseInitArrayDefault =
!V.isOlderThan(4, 7, 0) ||
getTriple().getArch() == llvm::Triple::aarch64 ||
getTriple().getEnvironment() == llvm::Triple::Android;
Or am I missing something obvious here?
Is it worthwhile to factor out only the 4 lines that add the -fuse-init-array
option into a separate function?
> -----Original Message-----
> From: Rafael Espíndola [mailto:rafael.espindola at gmail.com]
> Sent: 09 January 2014 16:25
> To: Kristof Beyls
> Cc: llvm cfe; Tim Northover
> Subject: Re: [PATCH] generate .init_array instead of .ctors sections for
> AArch64 ELF targets
> So .init_array should be used on BSDs only for aarch64?
> In any case, please refactor the clang code so that we don't add
> -fuse-init-array in two places (Generic_GCC::addClangTargetOptions and
> On 9 January 2014 10:28, Kristof Beyls <kristof.beyls at arm.com> wrote:
> > Hi,
> > The AArch64 C++ ABI states that .init_array sections should be used for
> > static constructors.
> > The attached patches (one for clang, one for LLVM), make sure that these
> > sections get
> > produced in an ABI-compliant way, not just for linux platforms, but for all
> > ELF-based
> > platforms. Could I get a review on these patches?
> > Thanks,
> > Kristof
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits