[LLVMdev] [lld] -emit-yaml doesnot contain linker added symbols specified with command line options
Nick Kledzik
kledzik at apple.com
Wed Aug 28 17:20:51 PDT 2013
On Aug 28, 2013, at 4:57 PM, Shankar Easwaran <shankare at codeaurora.org> wrote:
> On 8/28/2013 6:37 PM, Nick Kledzik wrote
>> $cat 1.c
>> int _start() { return 0; }
>> $gcc -c 1.c
>> $ld -u myundef 1.o
>> ==> Does not throw any error, the resolver was hinted that myundef was a undefined weak symbol.
>> Wow. Reading the gnu ld man page, that is not obvious. How can you make a non-weak undefined on the command line? That is, how can you force and error if something is not defined?
> I think the linker will barf only if the input file contained an undefined symbol and not by any other means.
>>>> Other options may need platform specific atoms which may be created with the help of static Writer methods.
>>> We wouldnt be able to override the functionality with each flavor, if we have a static method, or you had thought of something else ?
>> I’m not sure when we would want polymorphism. If you wanted it in this case, there could be a method on LinkingContext to create a file of UndefinedAtoms, and ELFLinkingContext could override that method to make weak undefines.
> Yes this will work for undefined atoms that need to be supported by all flavors. All the implicit files that are needed would be added to a vector of files in the inputGraph,
> addImplicitFiles would splice/prepend to the list of input files which it already has.
>
> Do you think that we still want the Writer::addFiles API, as this already covers the functionalities that is needed.
At least with mach-o there is a small advantage to having the MachOWriter create some atoms (as opposed to the MachOLinkingContext). For instance, the Writer needs to know which atom is the entry point. Current the MachOWriter creates the CRuntimeFile which has an atom X with a reference to UndefinedAtom for “_main”. When the Writer is called to generate the output file, it can look at the internal atom X and see what the reference now points to and use that as the entry. If the CRuntimeFile was created by the LinkingContext there would have to be an interface for the Writer to extract the entry target atom.
-Nick
More information about the llvm-dev
mailing list