[PATCH] [lld] Proposal and example for changing Atom attributes.

kledzik at apple.com kledzik at apple.com
Mon Aug 18 17:50:06 PDT 2014


Hi shankarke, atanasyan, ruiu, Bigcheese,

Currently, all the nodes in the Atom graph are read only because "const Atom" is used everywhere. But there are a few cases where it would be nice to make minor modifications to atoms.  For example, to implement the darwin linker option -expored_symbols_list, we need to be able to change the scope of atoms. ELF has a case where the dynamicExport attribute on an DefinedAtom may need to
be changed.

There is a couple parts to this patch:

1) Two new "notify" methods are added to LinkingContext. They are called by the global symbol table when an atom is added to the symbol table.

2) A setScope() method was added to DefinedAtom.  The base implementation just asserts.  

3) For mach-o, yaml, and native the setScope() method modifies the scope of the atom.  For the native reader, since the atom is just a pointer into a read-only file buffer, the new scope is stored in a side table.

4) The darwin driver has support for the -exported_symbols_list option.  The MachOLinkingContext notify methods watch for atoms being added to the symbol   table with match the symbol names specified by the exported symbols list
and adjust the scope as appropriate.

If the above goes into lld, then for the ELF issue where particular symbols are currently not be added to the .dynsym table, the fix would be to add a new method setDynamicExport(bool) to DefinedAtom, and in ELFLinkingContext implement the "notify" methods to notice the case (DefinedAtom overriding weak shared library atom) and call setDynamicExport(true) on that DefinedAtom.

http://reviews.llvm.org/D4965

Files:
  include/lld/Core/DefinedAtom.h
  include/lld/Core/LinkingContext.h
  include/lld/ReaderWriter/MachOLinkingContext.h
  lib/Core/DefinedAtom.cpp
  lib/Core/SymbolTable.cpp
  lib/Driver/DarwinLdDriver.cpp
  lib/Driver/DarwinLdOptions.td
  lib/ReaderWriter/MachO/Atoms.h
  lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lib/ReaderWriter/Native/ReaderNative.cpp
  lib/ReaderWriter/PECOFF/Atoms.h
  lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  test/mach-o/Inputs/exported_symbols_list.exp
  test/mach-o/exported_symbols_list.yaml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4965.12636.patch
Type: text/x-patch
Size: 19683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140819/48acec26/attachment.bin>


More information about the llvm-commits mailing list