Add OUTPUT_FORMAT linker script directive support.
authorRui Ueyama <ruiu@google.com>
Mon, 22 Oct 2018 20:50:01 +0000 (20:50 +0000)
committerRui Ueyama <ruiu@google.com>
Mon, 22 Oct 2018 20:50:01 +0000 (20:50 +0000)
commitea8cd00a1d1ae8ba47d749ca7bd2c9281e4b1847
tree9a48695cf58deed17a3eccedd09fe099794fc45b
parent01cc58bfb0139bf3a758d01c9985f78144d0c70c
Add OUTPUT_FORMAT linker script directive support.

This patch adds a support for OUTPUT_FORMAT linker script directive.
Since I'm not 100% confident with BFD names you can use in the directive
for all architectures, I added only a few in this patch. We can add
other names for other archtiectures later.

We still do not support triple-style OUTPUT_FORMAT directive, namely,
OUTPUT_FORMAT(bfdname, big, little). If you pass -EL (little endian)
or -EB (big endian) to the linker, GNU linkers pick up big or little
as a BFD name, correspondingly, so that you can use a single linker
script for bi-endian processor. I'm not sure if we really need to
support that, so I'll leave it alone for now.

Note that -m takes precedence over OUTPUT_FORAMT, but we always parse
a BFD name given to OUTPUT_FORMAT for error checking. You cannot write
an invalid name in the OUTPUT_FORMAT directive.

Differential Revision: https://reviews.llvm.org/D53495

llvm-svn: 344952
lld/ELF/ScriptParser.cpp
lld/test/ELF/emulation.s
lld/test/ELF/format-binary.test
lld/test/ELF/invalid-linkerscript.test
lld/test/ELF/linkerscript/output-format.s [deleted file]