[lld] r232341 - [ELF][ARM] Make gotSymbol a member.

Sean Silva chisophugis at gmail.com
Tue Mar 17 13:03:32 PDT 2015


On Tue, Mar 17, 2015 at 8:49 AM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 15 March 2015 at 20:54, Shankar Easwaran <shankare at codeaurora.org>
> wrote:
> > Author: shankare
> > Date: Sun Mar 15 19:54:03 2015
> > New Revision: 232341
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=232341&view=rev
> > Log:
> > [ELF][ARM] Make gotSymbol a member.
> >
> > The gotSymbol need not be a global static variable.
>
> But static is desirable.
>
> > Apart from this reason, This
> > variable was creating an issue with self hosting lld, as there seems to
> be an
> > issue running global initializers, when initializing the guard for this
> static
> > variable.
> >
>
> Could you just use
>
>
> static const char *gotSymbol;
>
>
> To avoid the static constructor?
>

We should be able to constant-fold StringRef("foo"), right? Saves computing
the length at runtime (if we need that).

-- Sean Silva


>
> > Program received signal SIGTRAP, Trace/breakpoint trap.
> >
> > Modified:
> >     lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
> >
> > Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
> > URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h?rev=232341&r1=232340&r2=232341&view=diff
> >
> ==============================================================================
> > --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h (original)
> > +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h Sun Mar 15
> 19:54:03 2015
> > @@ -41,18 +41,14 @@ protected:
> >  private:
> >    ARMLinkingContext &_context;
> >    ARMTargetLayout<ELFT> &_armLayout;
> > -
> > -  static StringRef gotSymbol;
> > +  StringRef _gotSymbol;
> >  };
> >
> >  template <class ELFT>
> > -StringRef ARMExecutableWriter<ELFT>::gotSymbol =
> "_GLOBAL_OFFSET_TABLE_";
> > -
> > -template <class ELFT>
> >  ARMExecutableWriter<ELFT>::ARMExecutableWriter(ARMLinkingContext
> &context,
> >                                                 ARMTargetLayout<ELFT>
> &layout)
> >      : ExecutableWriter<ELFT>(context, layout), _context(context),
> > -      _armLayout(layout) {}
> > +      _armLayout(layout), _gotSymbol("_GLOBAL_OFFSET_TABLE_") {}
> >
> >  template <class ELFT>
> >  bool ARMExecutableWriter<ELFT>::createImplicitFiles(
> > @@ -65,7 +61,7 @@ template <class ELFT>
> >  void ARMExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
> >    // Finalize the atom values that are part of the parent.
> >    ExecutableWriter<ELFT>::finalizeDefaultAtomValues();
> > -  auto gotAtomIter = _armLayout.findAbsoluteAtom(gotSymbol);
> > +  auto gotAtomIter = _armLayout.findAbsoluteAtom(_gotSymbol);
> >    if (gotAtomIter != _armLayout.absoluteAtoms().end()) {
> >      auto *gotAtom = *gotAtomIter;
> >      if (auto gotpltSection = _armLayout.findOutputSection(".got.plt"))
> > @@ -88,8 +84,8 @@ unique_bump_ptr<SymbolTable<ELFT>>
> >  template <class ELFT>
> >  void ARMExecutableWriter<ELFT>::processUndefinedSymbol(
> >      StringRef symName, CRuntimeFile<ELFT> &file) const {
> > -  if (symName == gotSymbol) {
> > -    file.addAbsoluteAtom(gotSymbol);
> > +  if (symName == _gotSymbol) {
> > +    file.addAbsoluteAtom(_gotSymbol);
> >    } else if (symName.startswith("__exidx")) {
> >      file.addAbsoluteAtom("__exidx_start");
> >      file.addAbsoluteAtom("__exidx_end");
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150317/5e9d05f7/attachment.html>


More information about the llvm-commits mailing list