[PATCH] D25279: [ELF] - Do not crash on large output.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 10:33:15 PDT 2016
ruiu added inline comments.
> Writer.cpp:1388-1389
> template <class ELFT> void Writer<ELFT>::openFile() {
> + if (FileSize > SIZE_MAX)
> + fatal("output file size is too large for this configuration");
> ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
You should consider the following four cases.
Host / Target
32/32 - This check will never fail and silently create broken file.
32/64 - This check will never fail but if you attempt to create a file larger than 4GB, the linker will crash at some point because we are using MMAP IO and the result won't fit in the memory space.
64/32 - This check can catch errors.
64/64 - This check will never fail and silently create broken files.
As you can see, it results in pretty inconsistent behavior.
If you really want to do something about it, please do this.
- Change FileSize's type to uint64_t
- and verify that `FileSize < SIZE_MAX && FileSize < sizeof(uintX_t)*8`.
https://reviews.llvm.org/D25279
More information about the llvm-commits
mailing list