diff -up ./src/elf.cc.2 ./src/elf.cc --- ./src/elf.cc.2 2020-08-02 17:34:06.872636546 -0400 +++ ./src/elf.cc 2020-08-02 17:34:26.293491457 -0400 @@ -794,12 +794,12 @@ void ForEachElf(const InputFile& file, R // // - 24 bits for index (up to 16M symbols with -ffunction-sections) // - 40 bits for address (up to 1TB section) -static uint64_t ToVMAddr(size_t addr, long ndx, bool is_object) { +static uint64_t ToVMAddr(uint64_t addr, int64_t ndx, bool is_object) { if (is_object) { if (ndx >= 1 << 24) { THROW("ndx overflow: too many sections"); } - if (addr >= 1UL << 40) { + if (addr >= 1ULL << 40) { THROW("address overflow: section too big"); } return (ndx << 40) | addr;