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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 04:38:26 PST 2018


grimar added a comment.

What is your use case? I wonder what is the reason to use `OUTPUT_ARCH` to **override** `-m`?

We started to support `OUTPUT_FORMAT` recently, but it does not override the
`EKind`, `EMachine` and `MipsN32Abi` values if they were already found from reading the files.



================
Comment at: ELF/ScriptParser.cpp:407
   expect("(");
-  while (!errorCount() && !consume(")"))
-    skip();
+  std::tie(Config->EKind, Config->EMachine) = readBfdArch();
+  expect(")");
----------------
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).


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