<html>
  <head>
    
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Shankar,<br>
    <br>
    Back when we started the discussion, you mentioned that you also
    wanted to take care of this case.<br>
    Will you do that or otherwise I'll work on it?<br>
    <br>
    - Denis.<br>
    <br>
    <div class="moz-cite-prefix">On 02/25/2015 05:25 PM, Shankar
      Easwaran wrote:<br>
    </div>
    <blockquote cite="mid:54EDDB55.5000100@codeaurora.org" type="cite">
      <meta content="text/html; charset=windows-1252"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">Adding it to the OutputELFWriter
        sounds good.<br>
        <br>
        On 2/25/2015 6:40 AM, Denis Protivensky wrote:<br>
      </div>
      <blockquote cite="mid:54EDC2D2.9080603@accesssoftek.com"
        type="cite">
        <pre wrap="">Okay, I understood that you're proposing to add all undefined symbols during the resolution step, and not try to collect extra symbols during execution and then check if some undefines left (as I originally planned).
This sounds reasonable as in any case we must have all undefines resolved in order to continue the linking process.

Concerning the implementation, why not to add this virtual archive file to the OutputELFWriter (or even to ExecutableWriter) since we already have a method to add specific files to the linking process?
We may then expose a simple interface to the descendants of the writers to give chance to handle undefines.

Also, do we need this special symbol handling for any cases other than static linking of the executable?

- Denis.

On 02/24/2015 06:44 AM, Nick Kledzik wrote:


On Feb 23, 2015, at 2:52 PM, Michael Spencer <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:bigcheesegs@gmail.com"><bigcheesegs@gmail.com></a><a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:bigcheesegs@gmail.com"><mailto:bigcheesegs@gmail.com></a> wrote:

</pre>
        <blockquote type="cite">
          <pre wrap="">On Thu, Feb 19, 2015 at 10:40 PM, Denis Protivensky
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:dprotivensky@accesssoftek.com"><dprotivensky@accesssoftek.com></a><a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:dprotivensky@accesssoftek.com"><mailto:dprotivensky@accesssoftek.com></a> wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">Shankar,

Okay, I guessed the correct interface.
But what about the moment at which the function is called?
If it's called from Resolver::resolve(), it doesn't make any difference to
me as I cannot determine the need of specific symbols at that time.

- Denis.
</pre>
          </blockquote>
          <pre wrap="">None of the symbols we are looking up require the full resolver, and
they are all special linker symbols. I propose two things.

1. Provide a hook as per what Shankar suggested for the resolver. User
references to linker defined symbols such as _GLOBAL_OFFSET_TABLE_ get
created and possibly deadstripped here. The linking context owns the
atom.
2. The ELFLinkingContext gains <Atom
*getOrCreateLinkerDefinedAtom(StringRef);>. This can be used in passes
to get the symbols. The hook in (1) would call this to create the
atoms.

This gives a single place where linker defined atoms are actually
created, and allows correct deadstripping and object file references
without doing multiple resolver passes.
</pre>
        </blockquote>
        <pre wrap="">As Rui showed, we already have this abstraction.  The linking context just adds a magic ArchiveFile.  When queried for any “linker defined symbol”, the magic ArchiveFile instantiates the atoms needed.

This is how mach-o handles linker defined symbols like __dso_handle.

-Nick


</pre>
        <blockquote type="cite">
          <blockquote type="cite">
            <pre wrap="">
On 02/19/2015 08:15 PM, Shankar Easwaran wrote:

+ Nick

On 2/19/2015 9:00 AM, Shankar Easwaran wrote:
</pre>
            <blockquote type="cite">
              <pre wrap="">On 2/19/2015 3:58 AM, Denis Protivensky wrote:
</pre>
              <blockquote type="cite">
                <pre wrap="">Joerg:
</pre>
                <blockquote type="cite">
                  <pre wrap="">I propose to add the ability to ignore undefined symbols during initial
resolution, and then postprocess only those undefines for the second
time
after the pass manager execution.
</pre>
                </blockquote>
                <pre wrap="">Do you want to do that before or after dead code elimination?
I think dead code elimination should be performed after all possible
object code modifications done by lld. Therefore, it should be done
after undefines' postprocessing as well.
</pre>
              </blockquote>
              <pre wrap="">Gnu does dead code elimination before undefines are reported. So if a
function is not called and it has a undefined reference its would not
be an undef.
</pre>
              <blockquote type="cite">
                <pre wrap="">Shankar:
</pre>
                <blockquote type="cite">
                  <pre wrap="">I propose to add the ability to ignore undefined symbols during initial
resolution, and then postprocess only those undefines for the second
time
after the pass manager execution.
</pre>
                </blockquote>
                <pre wrap="">I came across this same problem, and was planning on adding a
notifyUndefinedSymbol to the LinkingContext, if the linker wants to add
a defined symbol and coalesce it, it would be possible.

Do you think this will work for your case too ?
With this option, I don't see:
- how to postpone processing and reaction on undefines. If the
callback is called from within Resolver::resolve(), you should react
on it immediately, because otherwise the code will still fail in
Resolver::resolve().
- how to know if a symbol is needed within the callback body. The
need of any symbol is determined in some other place. So I need to
keep a sort of indication (boolean flags, whatever) to know which
symbols are really needed.
- the exact interface of notifyUndefinedSymbol callback. If it
receives `StringRef` name of the undefined symbol, what reaction
should be? Should it return new symbols to add back to the caller as
`const Atom*`?
</pre>
              </blockquote>
              <pre wrap="">notifyUndefinedSymbol will allow the context to coalesce the undefined
atom with a defined atom.

Atom *notifyUndefinedSymbol(StringRef name) could be the interface.

</pre>
              <blockquote type="cite">
                <pre wrap="">Thanks,
  Denis.

</pre>
              </blockquote>
              <pre wrap="">
</pre>
            </blockquote>
            <pre wrap="">
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
the Linux Foundation



_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:LLVMdev@cs.uiuc.edu"><mailto:LLVMdev@cs.uiuc.edu></a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>

</pre>
          </blockquote>
          <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:LLVMdev@cs.uiuc.edu"><mailto:LLVMdev@cs.uiuc.edu></a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
        </blockquote>
        <pre wrap="">

</pre>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
      </blockquote>
      <br>
      <br>
      <pre class="moz-signature" cols="72">-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
    </blockquote>
    <br>
  </body>
</html>