LLVM portability fix for abs(size)
size is actually an uint64_t, and LLVM drops the abs() on the principle that the uint64_t should always be positive. Make it explicit that we are converting to a signed integer first, by using abs((int)size) instead. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
5482a15e17
commit
ae01785d87
13 changed files with 14 additions and 14 deletions
|
@ -216,7 +216,7 @@ static void list_output(int32_t offset, const void *data,
|
|||
break;
|
||||
}
|
||||
case OUT_ADDRESS:
|
||||
list_address(offset, "[]", *(int64_t *)data, abs(size));
|
||||
list_address(offset, "[]", *(int64_t *)data, abs((int)size));
|
||||
break;
|
||||
case OUT_REL1ADR:
|
||||
list_address(offset, "()", *(int64_t *)data, 1);
|
||||
|
|
|
@ -634,7 +634,7 @@ static void aout_out(int32_t segto, const void *data,
|
|||
nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
|
||||
aout_sect_write(s, data, size);
|
||||
} else if (type == OUT_ADDRESS) {
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
addr = *(int64_t *)data;
|
||||
if (segment != NO_SEG) {
|
||||
if (segment % 2) {
|
||||
|
|
|
@ -347,7 +347,7 @@ static void as86_out(int32_t segto, const void *data,
|
|||
as86_sect_write(s, data, size);
|
||||
as86_add_piece(s, 0, 0L, 0L, size, 0);
|
||||
} else if (type == OUT_ADDRESS) {
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
if (segment != NO_SEG) {
|
||||
if (segment % 2) {
|
||||
nasm_error(ERR_NONFATAL, "as86 format does not support"
|
||||
|
|
|
@ -765,7 +765,7 @@ static void bin_out(int32_t segto, const void *data,
|
|||
switch (type) {
|
||||
case OUT_ADDRESS:
|
||||
{
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
if (segment != NO_SEG && !find_section_by_index(segment)) {
|
||||
if (segment % 2)
|
||||
|
|
|
@ -611,7 +611,7 @@ static void coff_out(int32_t segto, const void *data,
|
|||
dinfo.section = s;
|
||||
|
||||
if (type == OUT_ADDRESS)
|
||||
dinfo.size = abs(size);
|
||||
dinfo.size = abs((int)size);
|
||||
else
|
||||
dinfo.size = realsize(type, size);
|
||||
|
||||
|
@ -630,7 +630,7 @@ static void coff_out(int32_t segto, const void *data,
|
|||
nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
|
||||
coff_sect_write(s, data, size);
|
||||
} else if (type == OUT_ADDRESS) {
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
if (!win64) {
|
||||
if (asize != 4 && (segment != NO_SEG || wrt != NO_SEG)) {
|
||||
nasm_error(ERR_NONFATAL, "COFF format does not support non-32-bit"
|
||||
|
|
|
@ -730,7 +730,7 @@ static void elf_out(int32_t segto, const void *data,
|
|||
case OUT_ADDRESS:
|
||||
{
|
||||
bool gnu16 = false;
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
addr = *(int64_t *)data;
|
||||
if (segment != NO_SEG) {
|
||||
if (segment % 2) {
|
||||
|
|
|
@ -746,7 +746,7 @@ static void elf_out(int32_t segto, const void *data,
|
|||
case OUT_ADDRESS:
|
||||
{
|
||||
int isize = (int)size;
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
addr = *(int64_t *)data;
|
||||
if (segment == NO_SEG) {
|
||||
|
|
|
@ -745,7 +745,7 @@ static void elf_out(int32_t segto, const void *data,
|
|||
case OUT_ADDRESS:
|
||||
{
|
||||
int isize = (int)size;
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
addr = *(int64_t *)data;
|
||||
if (segment == NO_SEG) {
|
||||
|
|
|
@ -438,7 +438,7 @@ static void ieee_out(int32_t segto, const void *data,
|
|||
} else if (type == OUT_ADDRESS || type == OUT_REL2ADR ||
|
||||
type == OUT_REL4ADR) {
|
||||
if (type == OUT_ADDRESS)
|
||||
size = abs(size);
|
||||
size = abs((int)size);
|
||||
else if (segment == NO_SEG)
|
||||
nasm_error(ERR_NONFATAL, "relative call to absolute address not"
|
||||
" supported by IEEE format");
|
||||
|
|
|
@ -434,7 +434,7 @@ static void macho_output(int32_t secto, const void *data,
|
|||
|
||||
case OUT_ADDRESS:
|
||||
{
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
addr = *(int64_t *)data;
|
||||
|
||||
|
|
|
@ -536,7 +536,7 @@ static void macho_output(int32_t secto, const void *data,
|
|||
|
||||
case OUT_ADDRESS:
|
||||
{
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
addr = *(int64_t *)data;
|
||||
if (section != NO_SEG) {
|
||||
|
|
|
@ -1087,7 +1087,7 @@ static void obj_out(int32_t segto, const void *data,
|
|||
int rsize;
|
||||
|
||||
if (type == OUT_ADDRESS)
|
||||
size = abs(size);
|
||||
size = abs((int)size);
|
||||
|
||||
if (segment == NO_SEG && type != OUT_ADDRESS)
|
||||
nasm_error(ERR_NONFATAL, "relative call to absolute address not"
|
||||
|
|
|
@ -583,7 +583,7 @@ static void rdf2_out(int32_t segto, const void *data,
|
|||
|
||||
membufwrite(segto, data, size);
|
||||
} else if (type == OUT_ADDRESS) {
|
||||
int asize = abs(size);
|
||||
int asize = abs((int)size);
|
||||
|
||||
/* if segment == NO_SEG then we are writing an address of an
|
||||
object within the same segment - do not produce reloc rec. */
|
||||
|
|
Loading…
Reference in a new issue