<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">I think another way to do what you want is to add a new parameter to parse() to propagate library file name to the parser, so that the parser can determine if it's reading a library member. In this way you don't have to make a derived class of MemoryBuffer.</div><div class="gmail_quote"><br></div><div class="gmail_quote">One fault of that approach is the new parameter seems a bit arbitrary. In order to get file name, you would call MemoryBuffer::getIdentifier, but in order to get, you would use the second parameter of parse(). This is not wrong but looks odd.</div><div class="gmail_quote"><br></div><div class="gmail_quote">The other approach is to parse "filename(libraryname)" string returned from MemoryBuffer::getIdentifier. But this is of course not robust. (What if we have an object file whose file path contains parentheses?)</div><div class="gmail_quote"><br></div><div class="gmail_quote">So I think making a derived class would be fine.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Dec 2, 2014 at 9:24 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/2/2014 11:19 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Do you have to know whether a MemoryBuffer was in a library or not during<br>
parsing that MemoryBuffer?<br>
</blockquote></span>
Yes, I need to know that while parsing the buffer too.<div class="HOEnZb"><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If not, we could just set a library name to a File in<br>
FileArchive::instantiateMember after we call _registry.parseFile.<br>
<br>
On Tue, Dec 2, 2014 at 9:08 PM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Nick,<br>
<br>
Currently the Reader doesnot have  a way to figure out that a file that is<br>
being parsed is part of an archive.<br>
<br>
For linker script support this is needed to match a rule that matches only<br>
if the file is from an archive library (or a member of an archive.<br>
<br>
For example :-<br>
<br>
SECTIONS {<br>
.myoutputsection : {<br>
     libc.a : { *(.text) }<br>
     printf.o : { *(.rodata) }<br>
}<br>
}<br>
<br>
The colon is used to denote an archive file or a member of an archive file<br>
and the rule says pick all text sections from members of libc.a that the<br>
linker uses for the current link step.<br>
<br>
Current Design<br>
------------------------<br>
In the current design we record the archive file and the member in the<br>
memory buffer and identify using library(member) which is part of the<br>
MemoryBuffer.<br>
<br>
Information that needs to be recorded<br>
------------------------------<u></u>---------------------------<br>
The linker also needs to store the library and the member names separately<br>
as the linker script syntax allows to to distinguish library names and<br>
member names.<br>
<br>
Approach we could take is :-<br>
------------------------------<u></u>-------------<br>
a) Rename MemoryBuffer to LinkerMemoryBuffer, which is a container for<br>
MemoryBuffer but with extra information(that contains the filename and an<br>
optional member name)<br>
<br>
If the member name is not empty, the Reader could treat this as an archive<br>
member.<br>
<br>
Comments ??<br>
<br>
Shankar Easwaran<br>
<br>
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>
by the Linux Foundation<br>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
<br>
</blockquote></blockquote>
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</div></div></blockquote></div><br></div></div>