<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
The second case reflects programmer's mistake and cannot happen
because of wrong input, while the first one is possible. I'll change
the first to report fatal error instead.<br>
<br>
<div class="moz-cite-prefix">On 04/02/2015 12:59 AM, Rui Ueyama
wrote:<br>
</div>
<blockquote
cite="mid:CAJENXgsxxCUidGpX=zYb8PCbPRenMFCmTySg1XVAK=e77KzL1w@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Apr 1, 2015 at 4:36 AM, Denis
Protivensky <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dprotivensky@accesssoftek.com"
target="_blank">dprotivensky@accesssoftek.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Author:
denis-protivensky<br>
Date: Wed Apr 1 06:36:58 2015<br>
New Revision: 233798<br>
<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project?rev=233798&view=rev"
target="_blank">http://llvm.org/viewvc/llvm-project?rev=233798&view=rev</a><br>
Log:<br>
[ARM] Enhance checks for entry point<br>
<br>
Modified:<br>
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h<br>
<br>
Modified:
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h?rev=233798&r1=233797&r2=233798&view=diff"
target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h?rev=233798&r1=233797&r2=233798&view=diff</a><br>
==============================================================================<br>
---
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
(original)<br>
+++
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
Wed Apr 1 06:36:58 2015<br>
@@ -101,12 +101,22 @@ std::error_code
ARMExecutableWriter<ELFT<br>
if (std::error_code ec =
ExecutableWriter<ELFT>::setELFHeader())<br>
return ec;<br>
<br>
- // Fixup entry point for Thumb code.<br>
StringRef entryName = _ctx.entrySymbolName();<br>
if (const AtomLayout *al =
_armLayout.findAtomLayoutByName(entryName)) {<br>
- const auto *ea =
dyn_cast<DefinedAtom>(al->_atom);<br>
- if (ea && ea->codeModel() ==
DefinedAtom::codeARMThumb)<br>
- this->_elfHeader->e_entry(al->_virtualAddr
| 0x1);<br>
+ if (const auto *ea =
dyn_cast<DefinedAtom>(al->_atom)) {<br>
+ switch (ea->codeModel()) {<br>
+ case DefinedAtom::codeNA:<br>
+ if (al->_virtualAddr & 0x3)<br>
+ llvm_unreachable("Two least bits must be zero
for ARM entry point");<br>
+ break;<br>
+ case DefinedAtom::codeARMThumb:<br>
+ // Fixup entry point for Thumb code.<br>
+
this->_elfHeader->e_entry(al->_virtualAddr |
0x1);<br>
+ break;<br>
+ default:<br>
+ llvm_unreachable("Wrong code model of entry point
atom");<br>
+ }<br>
+ }<br>
}<br>
</blockquote>
<div> </div>
<div>Are these statements really unreachable, assuming
there's no bug in the code, or they might be reachable if
we give broken object files or something to the linker? I
don't know which is the case, but if the latter is the
case, you may want to use llvm::report_fatal_error instead
of llvm_unreachable because llvm_unreachable may be
expanded to __builtin_unreachable (so it may not print out
error messages).</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>