[PATCH] D55311: Add support for OUTPUT_ARCH linker script command

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 14:12:34 PST 2018


void marked an inline comment as done.
void added inline comments.


================
Comment at: ELF/ScriptParser.cpp:407
   expect("(");
-  while (!errorCount() && !consume(")"))
-    skip();
+  std::tie(Config->EKind, Config->EMachine) = readBfdArch();
+  expect(")");
----------------
grimar wrote:
> I did not debug it, but I think the following case would fail:
> 
> If you take 32bit object test32.o and a script saying the arch is 64,
> and invoke `ld.lld test32.o -T script`
> 
> then the script should override the EKind/EMachine and crash the linker somewhere
> (I suspect it will try to parse the files using a wrong `ELFT` then).
It doesn't look like that's the case:

```
[morbo at fawn:llvm] cat script 
OUTPUT_ARCH(i386:x86-64)
[morbo at fawn:llvm] clang -m32 -c z.c
[morbo at fawn:llvm] ./llvm.opt.obj/bin/ld.lld z.o -T script 
ld.lld: warning: cannot find entry symbol _start; defaulting to 0x401000
```


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55311/new/

https://reviews.llvm.org/D55311





More information about the llvm-commits mailing list