output: macho -- Check the actual size of 64-bit absolute address

Even though the size is set to 64-bit, actual value can be
in 32-bit range. In that case, the use of such absolute
address is prevented.

The side effect of 58d2ab17 is resolved.

https://bugzilla.nasm.us/show_bug.cgi?id=3392468

Reported-by: Richard Russell <rtrussell@gmail.com>
Reported-by: Michael Petch <mpetch@capp-sysware.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Chang S. Bae 2018-05-02 08:07:51 -07:00 committed by Cyrill Gorcunov
parent 713fd1ffc8
commit 69ed82447a

View File

@ -670,7 +670,8 @@ static void macho_output(int32_t secto, const void *data,
nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" section base references");
} else if (wrt == NO_SEG) {
if (fmt.ptrsize == 8 && asize != 8) {
if (fmt.ptrsize == 8 &&
(asize != 8 || addr <= UINT32_MAX)) {
nasm_error(ERR_NONFATAL,
"Mach-O 64-bit format does not support"
" 32-bit absolute addresses");