This is an archive of the discontinued LLVM Phabricator instance.

Make NaCl's use of .init_array for static constructors match Linux
ClosedPublic

Authored by dschuff on Mar 10 2015, 5:13 PM.

Details

Summary

The generic ELF TargetObjectFile defaults to .ctors, but Linux's
defaults to .init_array by calling InitializeELF with the value of
UseInitArray from TargetMachine. Make NaCl's behavior match.

Diff Detail

Event Timeline

dschuff updated this revision to Diff 21664.Mar 10 2015, 5:13 PM
dschuff retitled this revision from to Make NaCl's use of .init_array for static constructors match Linux.
dschuff updated this object.
dschuff added a reviewer: jvoung.
dschuff added a subscriber: Unknown Object (MLST).
jvoung edited edge metadata.Mar 10 2015, 6:04 PM

looks okay -- a couple nits

lib/Target/X86/X86TargetMachine.cpp
41

nit: the class is called "Linux" but now it applies to Linux and NaCl.

I wonder if the the X86ELFTargetObjectFile and X86Linux should just be merged.

It's kind of odd in terms of naming that the X86ELFTargetObjectFile doesn't call InitializeELF =)

The fact that some systems use ctors and others use init_array is supposed to be controlled by the TM.Options.UseInitArray not so much whether InitializeELF is called or not. On the other hand, I'm not sure if clang sets that option correctly for each user of ELF + X86, so that might be a reason to check that as a separate change.

test/CodeGen/X86/constructor.ll
33

nit: Can these be NACL-NEXT for uniformity?

dschuff updated this revision to Diff 21680.Mar 10 2015, 11:01 PM
dschuff edited edge metadata.
  • review comments
This revision was automatically updated to reflect the committed changes.