This is an archive of the discontinued LLVM Phabricator instance.

Implement STARTUP linker script command.
Needs ReviewPublic

Authored by ruiu on Nov 23 2016, 3:32 PM.

Details

Reviewers
Bigcheese
grimar
Summary

Implement STARTUP linker script command.

Event Timeline

ruiu updated this revision to Diff 79160.Nov 23 2016, 3:32 PM
ruiu updated this revision to Diff 79161.
ruiu retitled this revision from to Implement STARTUP linker script command..
ruiu updated this object.
ruiu added a reviewer: grimar.
ruiu added a subscriber: llvm-commits.
  • removed an unrelated change.
davide added a subscriber: davide.Nov 23 2016, 3:41 PM

GNU gold doesn't seem to implement this one, maybe the same effect can be obtained without a linkerscript? What are you planning to use this for?

[davide@cupiditate ~]$ cat script
STARTUP(mario)
[davide@cupiditate ~]$ ld.gold --script=script
ld.gold: error: script:1:1: syntax error, unexpected STARTUP, expecting $end
ld.gold: fatal error: unable to parse script file script
[davide@cupiditate ~]$ ld --script=script
ld: no input files
davide added inline comments.Nov 23 2016, 3:42 PM
ELF/Driver.cpp
695

Nit: lld not LLD.

ruiu added a comment.Nov 23 2016, 3:45 PM

Someone tweeted me that LLD doesn't have STARTUP, so I took it, and after that I realized that gold doesn't support that (funny that gold only recognizes token "STARTUP", so apparently someone tried to support it but didn't actually do anything more than that.)

I won't push it until at least a bug is filed.

ruiu added a comment.Nov 23 2016, 3:48 PM

LLVM and LLDB but lld? It feels odd that a proper noun is all lowercase letters.

In D27070#604903, @ruiu wrote:

Someone tweeted me that LLD doesn't have STARTUP, so I took it, and after that I realized that gold doesn't support that (funny that gold only recognizes token "STARTUP", so apparently someone tried to support it but didn't actually do anything more than that.)

I won't push it until at least a bug is filed.

I'm not necessarily against this feature, but would like to understand the use-case more. Can you ask them to open a bug on llvm.org for those of us not using twitter?

In D27070#604904, @ruiu wrote:

LLVM and LLDB but lld? It feels odd that a proper noun is all lowercase letters.

Apparently Michael chose the name, and it's the one we have in http://lld.llvm.org/
While here, it also feels very weird having lld not respecting acronyms, FWIW (e.g. Lto instead of LTO as it's spelled anywhere else in LLVM). I would like to make this change if you have no objections.

ruiu added a comment.Nov 23 2016, 3:56 PM

Are you suggesting renaming lld to LLD? I'm not even sure if LLD is an acronym (what is it short for -- maybe LLVM's LD?)

If lld is still an official name, I'd vote for renaming it to LLD. lld is a command name, but as a proper noun, it should be spelled in upper case unelss there's strong reason to not do so.

In D27070#604914, @ruiu wrote:

Are you suggesting renaming lld to LLD? I'm not even sure if LLD is an acronym (what is it short for -- maybe LLVM's LD?)

If lld is still an official name, I'd vote for renaming it to LLD. lld is a command name, but as a proper noun, it should be spelled in upper case unelss there's strong reason to not do so.

No, I don't personally want to rename lld to LLD (but I won't object if you want to do so).
I'm pointing that, in the source code, we should rename Lto to LTO (et similia).

ruiu added a comment.Nov 23 2016, 4:03 PM

Out of curiosity, why do you prefer lld over LLD?

In D27070#604925, @ruiu wrote:

Out of curiosity, why do you prefer lld over LLD?

I'm not necessarily in favor of it, but this seems the original name we have. What about the proposed rename?

ruiu added a comment.Nov 23 2016, 4:24 PM

LLD's (or lld's) coding style should be the same as LLVM's.

grimar added inline comments.Nov 24 2016, 3:16 AM
ELF/LinkerScript.cpp
1249

May be better to inline this ?

test/ELF/linkerscript/startup.s
4

This creates "startup.s.tmp.dir" folder for me inside tools\lld\test\ELF\linkerscript\Output.
And looks that is the only folder inside at this moment.
So out tests previously did not do that and that is inconsistency.

Do you plan to do that for all tests ?

13

llvm-objdump -s -section=.text ?

16

I would suggest not to check the address here. Latest changes like max page size shows
that we have lot of testcase failing for reasons they should not.

29

STARTUP file 'nosuchfile' not found ?

grimar added inline comments.Nov 24 2016, 3:45 AM
test/ELF/linkerscript/startup.s
4

I think I had to clarify why I noticed that. Usually I use msvs output tab to extract command line with arguments of failing test.

When test uses %t (like all out test do), line is something like:

23> $ "C:/access_softek/c_make_build_dir/Debug/bin\ld.lld.EXE" "--full-shutdown" "C:\xxx\tools\lld\test\ELF\Output\eh-frame-merge.s.tmp.o" "C:\xxx\tools\lld\test\ELF\Output\eh-frame-merge.s.tmp.o" "-o" "C:\xxx\tools\lld\test\ELF\Output\eh-frame-merge.s.tmp" "-shared"

So I can just copy it to MSVS property page to "command arguments" and use it for debugger.

This test is different and does not use %t and creates local files in separate folder.
Line for it is:

23> C:/xxx/Debug/bin\ld.lld.EXE --full-shutdown -o exe -script=script foo.o bar.o

So I also need to set "working directory" property.
What is not a huge problem but a bit less convinent. Especially when one test do that and other - not.