Bug 26513 - 629310abec8811510177101f3c7992dfd4be24dd breaks assembling PowerPC Linux kernels
Summary: 629310abec8811510177101f3c7992dfd4be24dd breaks assembling PowerPC Linux kernels
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-21 04:55 UTC by Nathan Chancellor
Modified: 2020-08-23 21:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Chancellor 2020-08-21 04:55:34 UTC
When building the Linux kernel for some PowerPC targets with LLVM + gas (since LLVM's integrated assembler is not quite on par with some assembly used in the Linux kernel) after 629310abec8811510177101f3c7992dfd4be24dd, the following error occurs:

$ make -skj"$(nproc)" ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- LLVM=1 O=out/ppc64 distclean pseries_defconfig arch/powerpc/kernel/entry_64.o
...
arch/powerpc/kernel/entry_64.S: Assembler messages:                                                          arch/powerpc/kernel/entry_64.S:541: Error: junk at end of line: `0b01010'
...

$ git bisect log
# bad: [c2fd7faea8f2c3a267f276ceb6a95f9f537ea7c1] Fix for incorrect breakpoint set in case of flang compiled binary
# good: [5a2296ac1b3c26cab589bddfded07a560e434d03] Use is_xcoff_format in binutils testsuite
git bisect start 'c2fd7faea8f2c3a267f276ceb6a95f9f537ea7c1' '5a2296ac1b3c26cab589bddfded07a560e434d03'
# good: [8c419a91d761989b824d1bbe3b4575068317181e] libctf: fixes for systems on which sizeof (void *) > sizeof (long)
git bisect good 8c419a91d761989b824d1bbe3b4575068317181e
# good: [5555c86d3e85e85d76555acdb955aba062beb02f] [gdb] Fix prop->const_val uses in gdbtypes.c
git bisect good 5555c86d3e85e85d76555acdb955aba062beb02f
# good: [404ec93359eaaf6a4284613e9c3ac014eea9383b] Only warn about malformed win32pstatus notes
git bisect good 404ec93359eaaf6a4284613e9c3ac014eea9383b
# good: [3d11c30a6e839cfc126353fd1b35960301a1b6a0] [gdb/testsuite] Fix charlen type in mixed-lang-stack.c
git bisect good 3d11c30a6e839cfc126353fd1b35960301a1b6a0
# good: [587a4371760ea2d4dc82571d488def304a3981ca] Add ChangeLog entries for previous commit.
git bisect good 587a4371760ea2d4dc82571d488def304a3981ca
# good: [2b272f449e8664977d0aafba82c416b27b5f2d6f] Use libiberty hash in gas/macro.c.
git bisect good 2b272f449e8664977d0aafba82c416b27b5f2d6f
# good: [f7a5981beb423a0bc03633ac8156d33d83ef41d6] Port ecoff.c to str_hash.
git bisect good f7a5981beb423a0bc03633ac8156d33d83ef41d6
# bad: [629310abec8811510177101f3c7992dfd4be24dd] Port gas/config/* to str_htab.
git bisect bad 629310abec8811510177101f3c7992dfd4be24dd
# good: [494b2fc8078502f84a2ff2a3402a5989b221526d] Port dw2gencfi.c to str_htab.
git bisect good 494b2fc8078502f84a2ff2a3402a5989b221526d
# first bad commit: [629310abec8811510177101f3c7992dfd4be24dd] Port gas/config/* to str_htab.

If you need further information or reproduction steps, I am happy to provide them.
Comment 1 Alan Modra 2020-08-21 10:10:31 UTC
Confirmed.  str_hash_insert replaces existing entries, the old hash_insert did not.  That's a problem when there are multiple entries for an instruction in the powerpc_opcodes table.  For example, the proper power4 dcbt is added to the hash table but -many results in it being replaced with the ppc dcbt.
Comment 2 Sourceware Commits 2020-08-23 12:42:46 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fe0e921f00237abd926cd9efaeedf758b17170de

commit fe0e921f00237abd926cd9efaeedf758b17170de
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 22 17:59:57 2020 +0930

    PR26513, 629310abec breaks assembling PowerPC Linux kernels
    
    Inserting with replacement is wrong for some gas hash table uses.
    This patch implements an htab_insert that conditionally replaces, and
    similarly for str_hash_insert.  str_hash_insert with replace=0 is
    roughly equivalent to the older hash_insert, and str_hash_insert with
    replace=1 to the older hash_jam, but return values are different.  I
    found it useful to know whether the slot was occupied prior to
    inserting/replacing.  I've also reinstated the fatal errors on messing
    up opcode tables with duplicates.
    
            PR 26513
            * hash.h (htab_insert): Update prototype and comment.
            (struct string_tuple): Make "value" a const void*.
            (string_tuple_alloc): Likewise.
            (str_hash_find, str_hash_find_n): Cast returned value.
            (str_hash_insert): Add "replace" parameter, and return slot pointer.
            Free alloc'd element when not inserted.
            * hash.c (htab_insert): Likewise.  Return slot when element exists,
            otherwise return NULL.
            * read.c (pop_insert): Insert into hash table without first searching.
            * config/tc-avr.c (md_begin): Likewise.
            * config/tc-msp430.c (md_begin): Likewise.
            * config/tc-nds32.c (nds32_init_nds32_pseudo_opcodes): Likewise.
            * config/tc-v850.c (md_begin): Likewise.
            * macro.c (do_formals, define_macro, macro_expand_body): Likewise.
            (delete_macro): Delete from hash table.
            * config/tc-tic54x.c (subsym_create_or_replace): Correct logic.
    
            * symbols.c (local_symbol_make, symbol_table_insert): Allow
            replacement of hash table entries.
            * config/obj-coff-seh.c (seh_hash_insert): Likewise.
            * config/obj-coff.c (tag_insert): Likewise.
            * config/tc-iq2000.c (iq2000_add_macro): Likewise.
            * config/tc-m68k.c (md_begin): Likewise for aliases.
            * config/tc-tic4x.c (tic4x_asg): Likewise.
            * config/tc-tic6x.c (md_begin): Likewise.
    
            * dw2gencfi.c (dwcfi_hash_find_or_make): Disallow replacement of
            hash table entries.
            * ecoff.c (add_string, get_tag): Likewise.
            * macro.c (expand_irp): Likewise.
            * config/obj-elf.c (build_additional_section_info): Likewise.
            * config/tc-aarch64.c (insert_reg_alias): Likewise.
            (checked_hash_insert): Likewise.
            * config/tc-alpha.c (get_alpha_reloc_tag, md_begin): Likewise.
            * config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
            (declare_addrtype, md_begin, arc_extcorereg): Likewise.
            * config/tc-arm.c (insert_reg_alias): Likewise.
            (arm_tc_equal_in_insn, md_begin): Likewise.
            * config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
            * config/tc-cris.c (md_begin): Likewise.
            * config/tc-crx.c (md_begin): Likewise.
            * config/tc-csky.c (md_begin): Likewise.
            * config/tc-d10v.c (md_begin): Likewise.
            * config/tc-dlx.c (md_begin): Likewise.
            * config/tc-ft32.c (md_begin): Likewise.
            * config/tc-h8300.c (md_begin): Likewise.
            * config/tc-hppa.c (md_begin): Likewise.
            * config/tc-i386.c (md_begin): Likewise.
            * config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
            (md_begin, dot_alias): Likewise.
            * config/tc-m68hc11.c (md_begin): Likewise.
            * config/tc-m68k.c (md_begin): Likewise.
            * config/tc-mcore.c (md_begin): Likewise.
            * config/tc-microblaze.c (md_begin): Likewise.
            * config/tc-mips.c (md_begin): Likewise.
            * config/tc-mmix.c (md_begin): Likewise.
            * config/tc-mn10200.c (md_begin): Likewise.
            * config/tc-mn10300.c (md_begin): Likewise.
            * config/tc-moxie.c (md_begin): Likewise.
            * config/tc-nds32.c (nds32_relax_hint, md_begin): Likewise.
            * config/tc-nios2.c (md_begin): Likewise.
            * config/tc-ns32k.c (md_begin): Likewise.
            * config/tc-pdp11.c (md_begin): Likewise.
            * config/tc-pj.c (fake_opcode, md_begin): Likewise.
            * config/tc-ppc.c (ppc_setup_opcodes): Likewise.
            * config/tc-pru.c (md_begin): Likewise.
            * config/tc-riscv.c (init_ext_version_hash): Likewise.
            (init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
            (riscv_init_csr_hash): Likewise.
            * config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
            * config/tc-score.c (s3_insert_reg): Likewise.
            (s3_build_score_ops_hsh, s3_build_dependency_insn_hsh): Likewise.
            * config/tc-score7.c (s7_build_score_ops_hsh): Likewise.
            (s7_build_dependency_insn_hsh, s7_insert_reg): Likewise.
            * config/tc-sh.c (md_begin): Likewise.
            * config/tc-sparc.c (md_begin): Likewise.
            * config/tc-spu.c (md_begin): Likewise.
            * config/tc-tic30.c (md_begin): Likewise.
            * config/tc-tic4x.c (tic4x_inst_insert): Likewise.
            * config/tc-tic54x.c (stag_add_field_symbols, md_begin): Likewise.
            (tic54x_endstruct, tic54x_var, tic54x_macro_info): Likewise.
            (subsym_substitute): Likewise.
            * config/tc-tilegx.c (md_begin): Likewise.
            * config/tc-tilepro.c (md_begin): Likewise.
            * config/tc-vax.c (vip_begin): Likewise.
            * config/tc-wasm32.c (md_begin): Likewise.
            * config/tc-xgate.c (md_begin): Likewise.
            * config/tc-z8k.c (md_begin): Likewise.
            * testsuite/gas/ppc/dcbt.d,
            * testsuite/gas/ppc/dcbt.s: New test.
            * testsuite/gas/ppc/ppc.exp: Run it.
    
            * ecoff.c (add_string): Report fatal error on duplicates.
            * config/tc-alpha.c (md_begin): Likewise.
            * config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
            (declare_addrtype, md_begin, arc_extcorereg): Likewise.
            * config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
            * config/tc-cris.c (md_begin): Likewise.
            * config/tc-crx.c (md_begin): Likewise.
            * config/tc-dlx.c (md_begin): Likewise.
            * config/tc-hppa.c (md_begin): Likewise.
            * config/tc-i386.c (md_begin): Likewise.
            * config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
            (md_begin): Likewise.
            * config/tc-m68k.c (md_begin): Likewise.
            * config/tc-mips.c (md_begin): Likewise.
            * config/tc-nios2.c (md_begin): Likewise.
            * config/tc-ns32k.c (md_begin): Likewise.
            * config/tc-ppc.c (ppc_setup_opcodes): Likewise.
            * config/tc-pru.c (md_begin): Likewise.
            * config/tc-riscv.c (init_ext_version_hash): Likewise.
            (init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
            * config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
            * config/tc-sparc.c (md_begin): Likewise.
            * config/tc-tic30.c (md_begin): Likewise.
            * config/tc-tic4x.c (tic4x_inst_insert): Likewise.
            * config/tc-tilegx.c (md_begin): Likewise.
            * config/tc-tilepro.c (md_begin): Likewise.
            * config/tc-vax.c (vip_begin): Likewise.
    
            * config/tc-alpha.c,
            * config/tc-arm.c,
            * config/tc-avr.c,
            * config/tc-cr16.c,
            * config/tc-csky.c,
            * config/tc-i386.c,
            * config/tc-m68hc11.c,
            * config/tc-m68k.c,
            * config/tc-microblaze.c,
            * config/tc-ns32k.c,
            * config/tc-pj.c,
            * config/tc-ppc.c,
            * config/tc-score.c,
            * config/tc-score7.c,
            * config/tc-tic4x.c,
            * config/tc-tic54x.c,
            * config/tc-tilegx.c,
            * config/tc-tilepro.c,
            * config/tc-xgate.c: Formatting.
Comment 3 Nathan Chancellor 2020-08-23 21:23:36 UTC
I can confirm that patch fixes this issue, thank you!