From fc633e5b9780011f74f2c23837968e43e262a239 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 13 Apr 2000 01:08:05 +0000 Subject: [PATCH] Remove U suffix from constants for K&R compilers. Fix a couple of 64 bit nits. --- bfd/ChangeLog | 16 ++++++++++++++++ bfd/coff-a29k.c | 6 +++--- bfd/elf32-d30v.c | 21 ++++++++------------- bfd/elf32-fr30.c | 4 ++-- bfd/elf32-hppa.h | 3 ++- bfd/elf32-mips.c | 8 ++++---- bfd/peicode.h | 4 ++-- gas/ChangeLog | 5 +++++ gas/config/tc-arm.c | 12 ++++++------ include/coff/ChangeLog | 5 +++++ include/coff/ti.h | 8 ++++---- 11 files changed, 57 insertions(+), 35 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d860c58..72d2896 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +2000-04-13 Alan Modra + + * elf32-hppa.h: Update copyright date. + + * elf32-fr30.c (fr30_elf_i20_reloc): Don't use U suffix. + * elf32-mips.c (_bfd_mips_elf_relocate_section): And here. + + * elf32-d30v.c (MAX32): Don't use LL suffix. + (MIN32): Define in terms of MAX32. + (bfd_elf_d30v_reloc): Make relocation a bfd_signed_vma. + + * coff-a29k.c (SIGN_EXTEND_HWORD): Replace with more concise + expression. + + * peicode.h (pe_ILF_build_a_bfd): Remove UL from hex constants. + 2000-04-12 Alan Modra * dep-in.sed: Match space before file name, not after. diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c index 0374b20..26d3c64 100644 --- a/bfd/coff-a29k.c +++ b/bfd/coff-a29k.c @@ -1,5 +1,5 @@ /* BFD back-end for AMD 29000 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 97, 98, 1999 + Copyright 1990, 91, 92, 93, 94, 95, 97, 98, 99, 2000 Free Software Foundation, Inc. Contributed by David Wood at New York University 7/8/91. @@ -43,9 +43,9 @@ static boolean coff_a29k_adjust_symndx #define INSERT_HWORD(WORD,HWORD) \ (((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff)) #define EXTRACT_HWORD(WORD) \ - ((((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff)) + ((((WORD) & 0x00ff0000) >> 8) | ((WORD) & 0xff)) #define SIGN_EXTEND_HWORD(HWORD) \ - ((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD)) + (((HWORD) ^ 0x8000) - 0x8000) /* Provided the symbol, returns the value reffed */ static long diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c index 263b5c0..601fb95 100644 --- a/bfd/elf32-d30v.c +++ b/bfd/elf32-d30v.c @@ -1,5 +1,5 @@ /* D30V-specific support for 32-bit ELF - Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 98, 99, 2000 Free Software Foundation, Inc. Contributed by Martin Hunt (hunt@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -263,8 +263,8 @@ static reloc_howto_type elf_d30v_howto_table[] = }; -#define MIN32 (long long)0xffffffff80000000LL -#define MAX32 0x7fffffffLL +#define MAX32 ((bfd_signed_vma) 0x7fffffff) +#define MIN32 (- MAX32 - 1) static bfd_reloc_status_type bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) @@ -276,7 +276,7 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, bfd *output_bfd; char **error_message; { - long long relocation; + bfd_signed_vma relocation; bfd_vma in1, in2, num; bfd_vma tmp_addr = 0; bfd_reloc_status_type r; @@ -360,15 +360,10 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, if (howto->pc_relative == true && howto->bitsize == 32) { - /* the D30V has a PC that doesn't wrap and PC-relative jumps */ - /* are signed, so a PC-relative jump can'tbe more than +/- 2^31 byrtes */ - /* if one exceeds this, change it to an absolute jump */ - if (relocation > MAX32) - { - relocation = (relocation + tmp_addr) & 0xffffffff; - make_absolute = 1; - } - else if (relocation < MIN32) + /* The D30V has a PC that doesn't wrap and PC-relative jumps are + signed, so a PC-relative jump can't be more than +/- 2^31 bytes. + If one exceeds this, change it to an absolute jump. */ + if (relocation > MAX32 || relocation < MIN32) { relocation = (relocation + tmp_addr) & 0xffffffff; make_absolute = 1; diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index 6b295d3..b150ec9 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -1,5 +1,5 @@ /* FR30-specific support for 32-bit ELF. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -275,7 +275,7 @@ fr30_elf_i20_reloc (abfd, reloc_entry, symbol, data, + symbol->section->output_offset + reloc_entry->addend; - if (relocation > ((1U << 20) - 1)) + if (relocation > (((bfd_vma) 1 << 20) - 1)) return bfd_reloc_overflow; x = bfd_get_32 (abfd, data + reloc_entry->address); diff --git a/bfd/elf32-hppa.h b/bfd/elf32-hppa.h index 915fc13..17c5e16 100644 --- a/bfd/elf32-hppa.h +++ b/bfd/elf32-hppa.h @@ -4,7 +4,8 @@ in the Stratus FTX/Golf Object File Format (SED-1762) dated February 1994. - Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 98, 99, 2000 + Free Software Foundation, Inc. Written by: diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index d8471bf..c1506e1 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -6739,8 +6739,8 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_vma low_bits; bfd_vma high_bits; - if (addend & 0x80000000u) - sign_bits = 0xffffffffu; + if (addend & ((bfd_vma) 1 << 31)) + sign_bits = ((bfd_vma) 1 << 32) - 1; else sign_bits = 0; @@ -6859,8 +6859,8 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_vma low_bits; bfd_vma high_bits; - if (value & 0x80000000u) - sign_bits = 0xffffffffu; + if (value & ((bfd_vma) 1 << 31)) + sign_bits = ((bfd_vma) 1 << 32) - 1; else sign_bits = 0; diff --git a/bfd/peicode.h b/bfd/peicode.h index 7238c78..1c58ad0 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -905,8 +905,8 @@ pe_ILF_build_a_bfd (bfd * abfd, /* XXX - treat as IMPORT_NAME ??? */ abort (); - * (unsigned int *) id4->contents = ordinal | 0x80000000UL; - * (unsigned int *) id5->contents = ordinal | 0x80000000UL; + * (unsigned int *) id4->contents = ordinal | 0x80000000; + * (unsigned int *) id5->contents = ordinal | 0x80000000; } else { diff --git a/gas/ChangeLog b/gas/ChangeLog index bacb74e..4bbe674 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2000-04-13 Alan Modra + + * config/tc-arm.c (md_apply_fix3): Don't use UL suffix on + constants, and don't assume offsetT is 32 bits. + 2000-04-12 Andrew Cagney * config/tc-d10v.h: Include "write.h" to get definition of fixS. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 53c6b2f..f4f7398 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -5571,8 +5571,8 @@ md_apply_fix3 (fixP, val, seg) instruction, in a 24 bit, signed field. Thus we need to check that none of the top 8 bits of the shifted value (top 7 bits of the unshifted, unsigned value) are set, or that they are all set. */ - if ((value & 0xfe000000UL) != 0 - && ((value & 0xfe000000UL) != 0xfe000000UL)) + if ((value & ~ ((offsetT) 0x1ffffff)) != 0 + && ((value & ~ ((offsetT) 0x1ffffff)) != ~ ((offsetT) 0x1ffffff))) { #ifdef OBJ_ELF /* Normally we would be stuck at this point, since we cannot store @@ -5595,8 +5595,8 @@ md_apply_fix3 (fixP, val, seg) /* Permit a backward branch provided that enough bits are set. Allow a forwards branch, provided that enough bits are clear. */ - if ((value & 0xfe000000UL) == 0xfe000000UL - || (value & 0xfe000000UL) == 0) + if ((value & ~ ((offsetT) 0x1ffffff)) == ~ ((offsetT) 0x1ffffff) + || (value & ~ ((offsetT) 0x1ffffff)) == 0) fixP->fx_done = 1; } @@ -5609,8 +5609,8 @@ md_apply_fix3 (fixP, val, seg) value >>= 2; value += SEXT24 (newval); - if ((value & 0xff000000UL) != 0 - && ((value & 0xff000000UL) != 0xff000000UL)) + if ((value & ~ ((offsetT) 0xffffff)) != 0 + && ((value & ~ ((offsetT) 0xffffff)) != ~ ((offsetT) 0xffffff))) as_bad_where (fixP->fx_file, fixP->fx_line, _("out of range branch")); diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog index e7ed338..5decdb2 100644 --- a/include/coff/ChangeLog +++ b/include/coff/ChangeLog @@ -1,3 +1,8 @@ +2000-04-13 Alan Modra + + * ti.h (ADDR_MASK): Don't use ul suffix on constants. + (PG_MASK): Ditto. + 2000-04-11 Timothy Wall * ti.h: Remove load page references until load pages are diff --git a/include/coff/ti.h b/include/coff/ti.h index 40f2d1c..306ad7b 100644 --- a/include/coff/ti.h +++ b/include/coff/ti.h @@ -252,10 +252,10 @@ PUT_SCNHDR_FLAGS(ABFD,((struct internal_scnhdr *)(INT))->s_flags, \ #define LONG_ADDRESSES 1 #define PG_SHIFT (LONG_ADDRESSES ? 30 : 16) -#define ADDR_MASK ((1ul<>PG_SHIFT) +#define ADDR_MASK (((unsigned long) 1 << PG_SHIFT) - 1) +#define PG_MASK ((unsigned long) 3 << PG_SHIFT) +#define PG_TO_FLAG(p) ((p) << PG_SHIFT) +#define FLAG_TO_PG(f) (((f) & PG_MASK) >> PG_SHIFT) /* * names of "special" sections -- 2.7.4