Open Quuxplusone opened 8 years ago
Bugzilla Link | PR26116 |
Status | NEW |
Importance | P release blocker |
Reported by | Vivien MILLET (vivien.millet@gmail.com) |
Reported on | 2016-01-11 13:17:03 -0800 |
Last modified on | 2016-02-24 05:53:03 -0800 |
Version | trunk |
Hardware | PC All |
CC | listhex@gmail.com, llvm-bugs@lists.llvm.org, vivien.millet@gmail.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Hi,
I've got the same assertion but in my case the external symbol is an address of
external function which is linked during RtDyld. So your instruction
Value -= FinalAddress + 4;
may give negative result if FinalAddress > Value and will get relocation
overflow.
I think the problem is in using of REL32 relocation for externals.
Hi, I agree on that point, REL32 shouldn't be used to locate absolute addresses
of external symbols. About the Value -= FinalAddress + 4; I've just adapted the
x64 version of the same code section in RuntimeDyldCOFFX86_64.h :
00069 case COFF::IMAGE_REL_AMD64_REL32:
00070 case COFF::IMAGE_REL_AMD64_REL32_1:
00071 case COFF::IMAGE_REL_AMD64_REL32_2:
00072 case COFF::IMAGE_REL_AMD64_REL32_3:
00073 case COFF::IMAGE_REL_AMD64_REL32_4:
00074 case COFF::IMAGE_REL_AMD64_REL32_5: {
00075 uint64_t FinalAddress = Section.getLoadAddressWithOffset(RE.Offset);
00076 // Delta is the distance from the start of the reloc to the end of
the
00077 // instruction with the reloc.
00078 uint64_t Delta = 4 + (RE.RelType - COFF::IMAGE_REL_AMD64_REL32);
00079 Value -= FinalAddress + Delta; // <------- HERE
00080 uint64_t Result = Value + RE.Addend;
00081 assert(((int64_t)Result <= INT32_MAX) && "Relocation overflow");
00082 assert(((int64_t)Result >= INT32_MIN) && "Relocation underflow");
00083 writeBytesUnaligned(Result, Target, 4);
00084 break;
00085 }