This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] - Implemented --allow-multiple-definition flag
ClosedPublic

Authored by grimar on Sep 25 2015, 10:48 AM.

Details

Reviewers
ruiu
rafael
Summary

Implementation of --allow-multiple-definition flag

For tests I created 2 functions with the same name but different first instruction. Then checking that order of files in linker cmd line affects on which one is used.
Should anything else be checked ?

Diff Detail

Event Timeline

grimar updated this revision to Diff 35735.Sep 25 2015, 10:48 AM
grimar retitled this revision from to [ELF2] - Implemented --allow-multiple-definition flag.
grimar updated this object.
grimar added reviewers: ruiu, rui314, rafael.
grimar added a project: lld.
grimar added subscribers: llvm-commits, grimar.
rafael edited edge metadata.Sep 25 2015, 1:57 PM

Please name the Input file Inputs/allow-multiple-definition.s.

test/elf2/allow-multiple-definition.s
7

Where is "%t" (with no number suffix) being created?

ruiu added inline comments.Sep 25 2015, 2:05 PM
ELF/SymbolTable.cpp
153–160

Usually when we concatenate strings, we use Twine. The new code uses String::operator+ instead, which is less preferred way to do the same thing. This would be better.

std::string Msg = (Twine("duplicate symbol: ") + Old.getName() + ...).str();

I also dropped "const" since it's obvious (and that use is more consistent with other code in LLD).

ruiu removed a reviewer: rui314.Sep 25 2015, 2:05 PM
ruiu edited edge metadata.

Also no need to send a patch to both ruiu and rui314. They are just me :) Please send patches to ruiu.

grimar updated this revision to Diff 35843.Sep 28 2015, 2:23 AM
grimar edited edge metadata.

Review comments addressed

grimar added inline comments.Sep 28 2015, 2:25 AM
ELF/SymbolTable.cpp
5–1

Ok. Fixed.

test/elf2/allow-multiple-definition.s
8

Good question. That definitely was a bug. Fixed.

I can't apply the patch:

$ git apply -p0 ~/Downloads/D13169.diff
/home/espindola/Downloads/D13169.diff:9: trailing whitespace.

bool AllowMultipleDefinition = false;

/home/espindola/Downloads/D13169.diff:21: trailing whitespace.

if (Args.hasArg(OPT_allow_multiple_definition))

/home/espindola/Downloads/D13169.diff:22: trailing whitespace.

Config->AllowMultipleDefinition = true;

/home/espindola/Downloads/D13169.diff:23: trailing whitespace.

/home/espindola/Downloads/D13169.diff:35: trailing whitespace.

error: patch failed: ELF/Config.h:25
error: ELF/Config.h: patch does not apply
error: patch failed: ELF/Driver.cpp:97
error: ELF/Driver.cpp: patch does not apply
error: patch failed: ELF/Options.td:37
error: ELF/Options.td: patch does not apply
error: patch failed: ELF/SymbolTable.cpp:150
error: ELF/SymbolTable.cpp: patch does not apply

@rafael wrote:

I can't apply the patch:

Hmm I thought I fixed that. Going to investigate then.

I can't apply the patch:

Looks like you need to use
--whitespace=warn flag as stated in
http://stackoverflow.com/questions/14509950/my-diff-contains-trailing-whitespace-how-to-get-rid-of-it

grimar updated this revision to Diff 35858.Sep 28 2015, 6:15 AM

Ot probably it was caused by CRLF. I thought I replaced them with LF but looks like no. I reuploaded the patch with LF instead of CRLF.

ruiu accepted this revision.Sep 28 2015, 10:50 AM
ruiu edited edge metadata.

LGTM

ELF/SymbolTable.cpp
155

This indentation looked weird at first but that is indeed clang-format would format. So this is what we want.

This revision is now accepted and ready to land.Sep 28 2015, 10:50 AM

I still have no write permissions. Could anyone commit this please ?

grimar closed this revision.Sep 29 2015, 1:34 AM

r248733