Skip to content

Commit

Permalink
more -Wconversion in bfd/elf32-*.c
Browse files Browse the repository at this point in the history
Change-Id: I75eea1441d7b799f4fa1819b0432708914be26c2
  • Loading branch information
cooljeanius committed Jan 8, 2024
1 parent 09feae0 commit df4d19f
Show file tree
Hide file tree
Showing 13 changed files with 421 additions and 412 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/apple-gdb-1824-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ jobs:
- run: test -e ./.profile_generic && test -r ./.profile_generic && source ./.profile_generic && (env | uniq | sort | uniq) && sync
- run: ./configure --enable-silent-rules CC=${{ matrix.compiler }} OBJC=${{ matrix.compiler }}
- run: make -ki -C libcheckpoint || make -ki -C libcheckpoint -f Makefile_orig || make -ki -C macsbug || make -ki -C macsbug/gdb_plugin_support || (if test -x "$(which ant)"; then ant; else echo "ant missing"; fi)
- run: if test ! -e libcheckpoint/libcheckpoint.dylib; then (echo "ensuring libcheckpoint is built" && sync && make -ki -C libcheckpoint -f Makefile_orig RC_CFLAGS="-std=gnu89 -w -Wno-error") || (sync && make -ki -C macsbug) || (sync && make -ki -C macsbug/gdb_plugin_support) || (if test -x "$(which ant)"; then ant; else echo "ant missing"; fi); else (sync && stat libcheckpoint/libcheckpoint.dylib); fi
- run: if test -d .. && test -w .. && test ! -e ../gdb; then (echo "symlinking source directory" && pushd .. && ln -sv apple-gdb-1824 gdb && sync && readlink gdb && popd); else (sync && stat .. && ls ..); fi
- run: if test ! -e libcheckpoint/libcheckpoint.dylib; then (sync && echo "ensuring libcheckpoint is built" && sync && make -ki -C libcheckpoint -f Makefile_orig RC_CFLAGS="-std=gnu89 -w -Wno-error" && sync) || (sync && make -ki -C macsbug) || (sync && make -ki -C macsbug/gdb_plugin_support) || (if test -x "$(which ant)"; then ant; else echo "ant missing"; fi); else (sync && stat libcheckpoint/libcheckpoint.dylib); fi
- run: if test -d .. && test -w .. && test ! -e ../gdb; then (echo "symlinking source directory" && pushd .. && ln -sv apple-gdb-1824 gdb && sync && readlink gdb && sync && popd); else (sync && stat .. && ls ..); fi
- run: (if test -n "$(type ant 2>/dev/null)" && test -x "$(which ant)" && test -r build.xml; then if test ! -d build; then mkdir build; elif test ! -d "${HOME}"/work/apple-gdb-1824/build; then mkdir -pv "${HOME}"/work/apple-gdb-1824/build; fi; ant; else (echo "ant missing" && sync); fi) || (if test -x ./gradlew; then (./gradlew build || ./gradlew assemble || ./gradlew); elif test -r ./gradlew; then sh ./gradlew; elif test -e ./gradlew; then stat ./gradlew; else echo "gradlewrapper missing"; fi) || (if test -x "$(which gradle)"; then gradle; else echo "gradle missing"; fi) || (if test -x ~rc/bin/buildit; then sudo ~rc/bin/buildit "$(pwd)" -arch ppc -arch i386 -arch armv5 -target cross -project gdb -release RELEASENAME RC_CROSS_ARCHS=armv6; else echo "buildit missing"; fi) || ls
- run: (if test -x ./gradlew; then (./gradlew build || ./gradlew assemble || ./gradlew); elif test -r ./gradlew; then sh ./gradlew; elif test -e ./gradlew; then stat ./gradlew; else echo "gradlewrapper missing" >&2; fi) || (if test -x "$(which gradle)"; then gradle; else echo "gradle missing"; fi) || (if test -x ~rc/bin/buildit; then sudo ~rc/bin/buildit "$(pwd)" -arch ppc -arch i386 -arch armv5 -target cross -project gdb -release RELEASENAME RC_CROSS_ARCHS=armv6; else echo "buildit missing"; fi) || ls
- run: cd src && ./configure --disable-werror --disable-opts-test --enable-carbon-framework --enable-debug-symbols-framework --enable-64-bit-bfd --enable-silent-rules CC=${{ matrix.compiler }} OBJC=${{ matrix.compiler }}
- run: cd src && make configure-bfd
- run: cd src && make -C bfd headers
- run: cd src && if test ! -e bfd/bfd.h; then make -C bfd bfd.h; else stat bfd/bfd.h; fi
- run: cd src && if test ! -e bfd/bfd.h; then (sync && make -C bfd bfd.h); else (sync && stat bfd/bfd.h); fi
- run: cd src && make -C bfd diststuff
- run: cd src && make all-bfd
- run: if test ! -e macsbug/MacsBug_plugin; then make -ki -C macsbug || make -ki -C macsbug/gdb_plugin_support || (if test -x "$(which ant)"; then ant; else echo "ant missing"; fi); else stat macsbug/MacsBug_plugin; fi
- run: if test ! -e macsbug/gdb_plugin_support/gdb_plugin_support.o; then make -ki -C macsbug/gdb_plugin_support TARGET_ARCHITECTURE="x86_64" || (if test -x "$(which ant)"; then ant; fi) || (for cfile in macsbug/gdb_plugin_support/*.c; do ${{ matrix.compiler }} -c "${cfile}" || stat "${cfile}"; done); else stat macsbug/gdb_plugin_support/gdb_plugin_support.o; fi
- run: if test ! -e macsbug/gdb_plugin_support/gdb_plugin_support.o; then (sync && make -ki -C macsbug/gdb_plugin_support TARGET_ARCHITECTURE="x86_64") || (if test -x "$(which ant)"; then ant; fi) || (for cfile in macsbug/gdb_plugin_support/*.c; do ${{ matrix.compiler }} -c "${cfile}" || stat "${cfile}"; done); else stat macsbug/gdb_plugin_support/gdb_plugin_support.o; fi
- run: cd src && make all-opcodes
- run: cd src && make configure-binutils
- name: Backup that annoying arparse.h header
Expand All @@ -53,28 +53,34 @@ jobs:
if test ! -e arparse.h; then \
echo "make my_arparse.h"; \
make my_arparse.h; \
else \
sync && stat arparse.h; \
fi
if test ! -f arparse.h; then \
echo "remake arparse.c"; \
remake arparse.c; \
else \
sync && wc -l arparse.h; \
fi
# shellcheck disable=SC2046
if test ! -e arparse.h; then \
echo "trying the relevant Makefile rule as copied into this CI workflow"; \
/bin/sh ./../ylwrap arparse.y y.tab.c arparse.c y.tab.h "$(echo arparse.c | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/)" y.output arparse.output -- $(if [ -f ../bison/bison ]; then echo ../bison/bison -y -L./../bison/; else echo bison -o y.tab.c; fi) -d -t -v -k; \
else \
sync && du arparse.h; \
fi
if test -e arparse.h; then \
if test ! -e ../bfd/arparse.h; then \
cp -v arparse.h ../bfd; \
sync && cp -v arparse.h ../bfd; \
elif test ! -e ../include/arparse.h; then \
cp -v arparse.h ../include; \
sync && cp -v arparse.h ../include; \
else \
stat arparse.h; \
sync && stat arparse.h; \
fi; \
else \
ls ./*.h || ls || pwd; \
fi
find . -name arparse.h -type f -print
sync && find . -name arparse.h -type f -print
- run: cd src && make all-binutils
- run: cd src && make all-cgen && make all-libiberty && make all-intl
- run: cd src && make all-electric-fence
Expand Down Expand Up @@ -116,21 +122,24 @@ jobs:
make check-local || make check stamp-framework ls; \
elif test ${{ matrix.compiler }} == gcc; then \
pushd bfd; \
make check-DEJAGNU; \
sync && make check-DEJAGNU; \
popd; \
pushd mmalloc; \
make info dvi stamp-framework-headers ls; \
sync && make info dvi stamp-framework-headers ls; \
popd; \
pushd electric-fence; \
make check stamp-framework ls; \
sync && make check stamp-framework ls; \
popd; \
pushd readline; \
make lint || make lint-local || make my_TAGS || make tags-local; \
popd; \
else \
echo "error, unhandled compiler!" >&2 && exit 1; \
fi
- run: cd src && make check-opcodes && make check-intl
- run: cd src && make check-opcodes && sync && make check-intl
- run: cd src && make check-binutils
- run: cd src && make check-utils
- run: time (pwd && ls)
- run: time (pwd && sync && ls)
if: "${{ success() }}"
- name: Upload a Build Artifact
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
else \
(sync && stat /home/runner/work/apple-gdb-1824/build); \
fi
cd src
(cd src && sync && echo "now in $(pwd)...")
- name: Dependencies
if: matrix.language == 'c-cpp'
Expand Down
6 changes: 3 additions & 3 deletions src/bfd/elf32-crx.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,10 @@ elf32_crx_relax_delete_bytes (struct bfd_link_info *link_info, bfd *abfd,
}

/* Now adjust the global symbols defined in this section. */
symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
symcount = ((symtab_hdr->sh_size / sizeof(Elf32_External_Sym))
- symtab_hdr->sh_info);
sym_hashes = start_hashes = elf_sym_hashes (abfd);
end_hashes = sym_hashes + symcount;
sym_hashes = start_hashes = elf_sym_hashes(abfd);
end_hashes = (sym_hashes + symcount);

for (; sym_hashes < end_hashes; sym_hashes++)
{
Expand Down
100 changes: 46 additions & 54 deletions src/bfd/elf32-dlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,126 +105,118 @@ _bfd_dlx_elf_hi16_reloc(bfd *abfd, arelent *reloc_entry, asymbol *symbol,
relocatable output against an external symbol. */

static bfd_reloc_status_type
elf32_dlx_relocate16 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
const char **error_message ATTRIBUTE_UNUSED)
elf32_dlx_relocate16(bfd *abfd, arelent *reloc_entry, asymbol *symbol,
void *data, asection *input_section, bfd *output_bfd,
const char **error_message ATTRIBUTE_UNUSED)
{
unsigned long insn, vallo, allignment;
int val;
int val;

/* HACK: I think this first condition is necessary when producing
relocatable output. After the end of HACK, the code is identical
to bfd_elf_generic_reloc(). I would _guess_ the first change
belongs there rather than here. martindo 1998-10-23. */

if (skip_dlx_elf_hi16_reloc)
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
return bfd_elf_generic_reloc(abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message);

/* Check undefined section and undefined symbols. */
if (bfd_is_und_section (symbol->section)
&& output_bfd == (bfd *) NULL)
if (bfd_is_und_section(symbol->section)
&& output_bfd == (bfd *)NULL)
return bfd_reloc_undefined;

/* Can not support a long jump to sections other then .text. */
if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
if (strcmp(input_section->name, symbol->section->output_section->name) != 0)
{
fprintf (stderr,
"BFD Link Error: branch (PC rel16) to section (%s) not supported\n",
symbol->section->output_section->name);
fprintf(stderr,
"BFD Link Error: branch (PC rel16) to section (%s) not supported\n",
symbol->section->output_section->name);
return bfd_reloc_undefined;
}

insn = bfd_get_32 (abfd, (bfd_byte *)data + reloc_entry->address);
allignment = 1 << (input_section->output_section->alignment_power - 1);
vallo = insn & 0x0000FFFF;
insn = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
allignment = (1 << (input_section->output_section->alignment_power - 1));
vallo = (insn & 0x0000FFFF);

if (vallo & 0x8000)
vallo = ~(vallo | 0xFFFF0000) + 1;
vallo = (~(vallo | 0xFFFF0000) + 1);

/* vallo points to the vma of next instruction. */
vallo += (((unsigned long)(input_section->output_section->vma +
input_section->output_offset) +
allignment) & ~allignment);

/* val is the displacement (PC relative to next instruction). */
val = (symbol->section->output_offset +
symbol->section->output_section->vma +
symbol->value) - vallo;
val = ((symbol->section->output_offset
+ symbol->section->output_section->vma
+ symbol->value)
- (int)vallo);

if (abs ((int) val) > 0x00007FFF)
if (abs((int)val) > 0x00007FFF)
return bfd_reloc_outofrange;

insn = (insn & 0xFFFF0000) | (val & 0x0000FFFF);
insn = (insn & 0xFFFF0000) | (val & 0x0000FFFF);

bfd_put_32 (abfd, insn,
(bfd_byte *) data + reloc_entry->address);
bfd_put_32(abfd, insn, (bfd_byte *)data + reloc_entry->address);

return bfd_reloc_ok;
}

/* */
static bfd_reloc_status_type
elf32_dlx_relocate26 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
const char **error_message ATTRIBUTE_UNUSED)
elf32_dlx_relocate26(bfd *abfd, arelent *reloc_entry, asymbol *symbol,
void *data, asection *input_section, bfd *output_bfd,
const char **error_message ATTRIBUTE_UNUSED)
{
unsigned long insn, vallo, allignment;
int val;
int val;

/* HACK: I think this first condition is necessary when producing
relocatable output. After the end of HACK, the code is identical
to bfd_elf_generic_reloc(). I would _guess_ the first change
belongs there rather than here. martindo 1998-10-23. */

if (skip_dlx_elf_hi16_reloc)
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
return bfd_elf_generic_reloc(abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message);

/* Check undefined section and undefined symbols. */
if (bfd_is_und_section (symbol->section)
&& output_bfd == (bfd *) NULL)
if (bfd_is_und_section(symbol->section)
&& output_bfd == (bfd *)NULL)
return bfd_reloc_undefined;

/* Can not support a long jump to sections other then .text */
if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
if (strcmp(input_section->name, symbol->section->output_section->name) != 0)
{
fprintf (stderr,
"BFD Link Error: jump (PC rel26) to section (%s) not supported\n",
symbol->section->output_section->name);
fprintf(stderr,
"BFD Link Error: jump (PC rel26) to section (%s) not supported\n",
symbol->section->output_section->name);
return bfd_reloc_undefined;
}

insn = bfd_get_32 (abfd, (bfd_byte *)data + reloc_entry->address);
allignment = 1 << (input_section->output_section->alignment_power - 1);
vallo = insn & 0x03FFFFFF;
insn = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
allignment = (1 << (input_section->output_section->alignment_power - 1));
vallo = (insn & 0x03FFFFFF);

if (vallo & 0x03000000)
vallo = ~(vallo | 0xFC000000) + 1;
vallo = (~(vallo | 0xFC000000) + 1);

/* vallo is the vma for the next instruction. */
vallo += (((unsigned long) (input_section->output_section->vma +
input_section->output_offset) +
vallo += (((unsigned long)(input_section->output_section->vma
+ input_section->output_offset) +
allignment) & ~allignment);

/* val is the displacement (PC relative to next instruction). */
val = (symbol->section->output_offset +
symbol->section->output_section->vma + symbol->value)
- vallo;
val = ((symbol->section->output_offset
+ symbol->section->output_section->vma + symbol->value)
- (int)vallo);

if (abs ((int) val) > 0x01FFFFFF)
if (abs((int)val) > 0x01FFFFFF)
return bfd_reloc_outofrange;

insn = (insn & 0xFC000000) | (val & 0x03FFFFFF);
bfd_put_32 (abfd, insn,
(bfd_byte *) data + reloc_entry->address);
insn = ((insn & 0xFC000000) | (val & 0x03FFFFFF));
bfd_put_32(abfd, insn, (bfd_byte *)data + reloc_entry->address);

return bfd_reloc_ok;
}
Expand Down
42 changes: 22 additions & 20 deletions src/bfd/elf32-fr30.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,47 +507,49 @@ fr30_elf_relocate_section(bfd *output_bfd, struct bfd_link_info *info,
const char *name;
int r_type;

r_type = ELF32_R_TYPE (rel->r_info);
r_type = ELF32_R_TYPE(rel->r_info);

if ( r_type == R_FR30_GNU_VTINHERIT
|| r_type == R_FR30_GNU_VTENTRY)
if ((r_type == R_FR30_GNU_VTINHERIT)
|| (r_type == R_FR30_GNU_VTENTRY))
continue;

r_symndx = ELF32_R_SYM (rel->r_info);
r_symndx = ELF32_R_SYM(rel->r_info);

howto = fr30_elf_howto_table + ELF32_R_TYPE (rel->r_info);
h = NULL;
sym = NULL;
sec = NULL;
howto = (fr30_elf_howto_table + ELF32_R_TYPE(rel->r_info));
h = NULL;
sym = NULL;
sec = NULL;

if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
sym = (local_syms + r_symndx);
sec = local_sections [r_symndx];
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
relocation = _bfd_elf_rela_local_sym(output_bfd, sym, &sec, rel);

name = bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name);
name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
name =
bfd_elf_string_from_elf_section(input_bfd,
(unsigned int)symtab_hdr->sh_link,
(unsigned int)sym->st_name);
name = ((name == NULL) ? bfd_section_name(input_bfd, sec) : name);
}
else
{
bfd_boolean unresolved_reloc, warned;

RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
r_symndx, symtab_hdr, sym_hashes,
h, sec, relocation,
unresolved_reloc, warned);
RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel,
r_symndx, symtab_hdr, sym_hashes,
h, sec, relocation,
unresolved_reloc, warned);

name = h->root.root.string;
}

r = fr30_final_link_relocate (howto, input_bfd, input_section,
contents, rel, relocation);
r = fr30_final_link_relocate(howto, input_bfd, input_section,
contents, rel, relocation);

if (r != bfd_reloc_ok)
{
const char * msg = (const char *) NULL;
const char *msg = (const char *)NULL;

switch (r)
{
Expand Down
11 changes: 6 additions & 5 deletions src/bfd/elf32-frv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,20 +1139,21 @@ struct frvfdpic_relocs_info

/* Compute a hash with the key fields of an frvfdpic_relocs_info entry. */
static hashval_t
frvfdpic_relocs_info_hash (const void *entry_)
frvfdpic_relocs_info_hash(const void *entry_)
{
const struct frvfdpic_relocs_info *entry =
(const struct frvfdpic_relocs_info *)entry_;

return (entry->symndx == -1
? (long) entry->d.h->root.root.hash
: entry->symndx + (long) entry->d.abfd->id * 257) + entry->addend;
return (((entry->symndx == -1)
? (long)entry->d.h->root.root.hash
: (entry->symndx + ((long)entry->d.abfd->id * 257L)))
+ (hashval_t)entry->addend);
}

/* Test whether the key fields of two frvfdpic_relocs_info entries are
identical. */
static int
frvfdpic_relocs_info_eq (const void *entry1, const void *entry2)
frvfdpic_relocs_info_eq(const void *entry1, const void *entry2)
{
const struct frvfdpic_relocs_info *e1 =
(const struct frvfdpic_relocs_info *)entry1;
Expand Down
Loading

0 comments on commit df4d19f

Please sign in to comment.