<div dir="ltr">It would be nice if we still print the number too. For example, I think that after this patch, for an unknown relocation we will just print "Unknown" and not give even the number.<div><br></div><div>Even when we have a name, printing the number can be convenient too (to e.g. find it in a hex editor etc. without doing an extra lookup).<div><br></div><div>-- Sean Silva</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 7, 2016 at 11:10 AM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Tue Jun 7 13:10:12 2016<br>
New Revision: 272034<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272034&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272034&view=rev</a><br>
Log:<br>
Define a helper function to get a relocation name. NFC.<br>
<br>
Modified:<br>
lld/trunk/ELF/Target.cpp<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272034&r1=272033&r2=272034&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272034&r1=272033&r2=272034&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Tue Jun 7 13:10:12 2016<br>
@@ -47,36 +47,36 @@ TargetInfo *Target;<br>
<br>
static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }<br>
<br>
+static StringRef getRelName(uint32_t Type) {<br>
+ return getELFRelocationTypeName(Config->EMachine, Type);<br>
+}<br>
+<br>
template <unsigned N> static void checkInt(int64_t V, uint32_t Type) {<br>
if (isInt<N>(V))<br>
return;<br>
- StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
- error("relocation " + S + " out of range");<br>
+ error("relocation " + getRelName(Type) + " out of range");<br>
}<br>
<br>
template <unsigned N> static void checkUInt(uint64_t V, uint32_t Type) {<br>
if (isUInt<N>(V))<br>
return;<br>
- StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
- error("relocation " + S + " out of range");<br>
+ error("relocation " + getRelName(Type) + " out of range");<br>
}<br>
<br>
template <unsigned N> static void checkIntUInt(uint64_t V, uint32_t Type) {<br>
if (isInt<N>(V) || isUInt<N>(V))<br>
return;<br>
- StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
- error("relocation " + S + " out of range");<br>
+ error("relocation " + getRelName(Type) + " out of range");<br>
}<br>
<br>
template <unsigned N> static void checkAlignment(uint64_t V, uint32_t Type) {<br>
if ((V & (N - 1)) == 0)<br>
return;<br>
- StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
- error("improper alignment for relocation " + S);<br>
+ error("improper alignment for relocation " + getRelName(Type));<br>
}<br>
<br>
static void warnDynRel(uint32_t Type) {<br>
- error("relocation " + getELFRelocationTypeName(Config->EMachine, Type) +<br>
+ error("relocation " + getRelName(Type) +<br>
" cannot be used when making a shared object; recompile with -fPIC.");<br>
}<br>
<br>
@@ -617,10 +617,8 @@ void X86_64TargetInfo::writePlt(uint8_t<br>
}<br>
<br>
uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {<br>
- if (Type == R_X86_64_PC32 || Type == R_X86_64_32)<br>
- if (Config->Shared)<br>
- error(getELFRelocationTypeName(EM_X86_64, Type) +<br>
- " cannot be a dynamic relocation");<br>
+ if (Config->Shared && (Type == R_X86_64_PC32 || Type == R_X86_64_32))<br>
+ error(getRelName(Type) + " cannot be a dynamic relocation");<br>
return Type;<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>