[lld] r226632 - Fix --start-group/end-group.
Rui Ueyama
ruiu at google.com
Wed Jan 21 10:52:19 PST 2015
Yes it does.
On Tue, Jan 20, 2015 at 7:26 PM, Shankar Easwaran <shankare at codeaurora.org>
wrote:
> Does the test you changed, test the fix for start/end group ?
>
>
> On 1/20/2015 7:26 PM, Rui Ueyama wrote:
>
>> Author: ruiu
>> Date: Tue Jan 20 19:26:43 2015
>> New Revision: 226632
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=226632&view=rev
>> Log:
>> Fix --start-group/end-group.
>>
>> We used to manage the state whether we are in a group or not
>> using a counter. The counter is incremented by one if we jump from
>> end-group to start-group, and decremented by one if we don't.
>> The counter was assumed to be either zero or one, but obviously it
>> could be negative (if there's a group which is not repeated at all).
>> This is a fix for that issue.
>>
>> Modified:
>> lld/trunk/include/lld/Core/Resolver.h
>> lld/trunk/lib/Core/Resolver.cpp
>> lld/trunk/test/pecoff/Inputs/vars-main-x86.obj.yaml
>>
>> Modified: lld/trunk/include/lld/Core/Resolver.h
>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/
>> Core/Resolver.h?rev=226632&r1=226631&r2=226632&view=diff
>> ============================================================
>> ==================
>> --- lld/trunk/include/lld/Core/Resolver.h (original)
>> +++ lld/trunk/include/lld/Core/Resolver.h Tue Jan 20 19:26:43 2015
>> @@ -58,7 +58,7 @@ private:
>> typedef std::function<void(StringRef, bool)> UndefCallback;
>> bool undefinesAdded(int begin, int end);
>> - File *getFile(int &index, int &groupLevel);
>> + File *getFile(int &index, bool &inGroup);
>> /// \brief Add section group/.gnu.linkonce if it does not exist
>> previously.
>> void maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);
>>
>> Modified: lld/trunk/lib/Core/Resolver.cpp
>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/
>> Resolver.cpp?rev=226632&r1=226631&r2=226632&view=diff
>> ============================================================
>> ==================
>> --- lld/trunk/lib/Core/Resolver.cpp (original)
>> +++ lld/trunk/lib/Core/Resolver.cpp Tue Jan 20 19:26:43 2015
>> @@ -254,7 +254,7 @@ bool Resolver::undefinesAdded(int begin,
>> return false;
>> }
>> -File *Resolver::getFile(int &index, int &groupLevel) {
>> +File *Resolver::getFile(int &index, bool &inGroup) {
>> std::vector<std::unique_ptr<Node>> &inputs = _context.getNodes();
>> if ((size_t)index >= inputs.size())
>> return nullptr;
>> @@ -265,12 +265,12 @@ File *Resolver::getFile(int &index, int
>> int size = group->getSize();
>> if (undefinesAdded(index - size, index)) {
>> index -= size;
>> - ++groupLevel;
>> - return getFile(index, groupLevel);
>> + inGroup = true;
>> + return getFile(index, inGroup);
>> }
>> ++index;
>> - --groupLevel;
>> - return getFile(index, groupLevel);
>> + inGroup = false;
>> + return getFile(index, inGroup);
>> }
>> return cast<FileNode>(inputs[index++].get())->getFile();
>> }
>> @@ -290,10 +290,10 @@ void Resolver::makePreloadArchiveMap() {
>> bool Resolver::resolveUndefines() {
>> ScopedTask task(getDefaultDomain(), "resolveUndefines");
>> int index = 0;
>> - int groupLevel = 0;
>> + bool inGroup = false;
>> for (;;) {
>> bool undefAdded = false;
>> - File *file = getFile(index, groupLevel);
>> + File *file = getFile(index, inGroup);
>> if (!file)
>> return true;
>> if (std::error_code ec = file->parse()) {
>> @@ -304,7 +304,7 @@ bool Resolver::resolveUndefines() {
>> file->beforeLink();
>> switch (file->kind()) {
>> case File::kindObject:
>> - if (groupLevel > 0)
>> + if (inGroup)
>> break;
>> assert(!file->hasOrdinal());
>> file->setOrdinal(_context.getNextOrdinalAndIncrement());
>>
>> Modified: lld/trunk/test/pecoff/Inputs/vars-main-x86.obj.yaml
>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/
>> Inputs/vars-main-x86.obj.yaml?rev=226632&r1=226631&r2=226632&view=diff
>> ============================================================
>> ==================
>> --- lld/trunk/test/pecoff/Inputs/vars-main-x86.obj.yaml (original)
>> +++ lld/trunk/test/pecoff/Inputs/vars-main-x86.obj.yaml Tue Jan 20
>> 19:26:43 2015
>> @@ -60,4 +60,10 @@ symbols:
>> SimpleType: IMAGE_SYM_TYPE_NULL
>> ComplexType: IMAGE_SYM_DTYPE_NULL
>> StorageClass: IMAGE_SYM_CLASS_EXTERNAL
>> + - Name: ___ImageBase
>> + Value: 0
>> + SectionNumber: 0
>> + SimpleType: IMAGE_SYM_TYPE_NULL
>> + ComplexType: IMAGE_SYM_DTYPE_NULL
>> + StorageClass: IMAGE_SYM_CLASS_EXTERNAL
>> ...
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by the Linux Foundation
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150121/8150c262/attachment.html>
More information about the llvm-commits
mailing list