Bug 19441 - mips sim mishandles micromips logic
Summary: mips sim mishandles micromips logic
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: unknown
: P2 normal
Target Milestone: ---
Assignee: Andrew Bennett
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-10 07:47 UTC by Mike Frysinger
Modified: 2016-01-18 21:53 UTC (History)
2 users (show)

See Also:
Host:
Target: mips-elf
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2016-01-10 07:47:00 UTC
when building for --target=mips-elf, the mips sim does:
mips.igen:
:include:::micromips.igen
:include:::micromipsdsp.igen

except micromips.igen also does:
:function:::address_word:delayslot_micromips:address_word target, address_word nia, int delayslot_instruction_size
...
  micromips_instruction_decode (SD, CPU, CIA, delayslot_instruction_size);
...

and that function is defined in micromipsrun.c which is not included in the build.  all of which leads to a link failure:
gcc -DHAVE_CONFIG_H    -DPROFILE=1 -DWITH_PROFILE=-1  -DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT -DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31 -DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG  -DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32 -DWITH_HW=0 -DDEFAULT_INLINE=0  -DWITH_RESERVED_BITS=1  -DWITH_SMP=0 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral    -DMIPS_MACH_DEFAULT=bfd_mach_mips8000   -I. -I../../../../sim/mips -I../common -I../../../../sim/mips/../common -I../../include -I../../../../sim/mips/../..//include -I../../bfd -I../../../../sim/mips/../..//bfd -I../../opcodes -I../../../../sim/mips/../..//opcodes  -g -O2 -static-libstdc++ -static-libgcc  -o run \
  nrun.o libsim.a ../../bfd/libbfd.a ../../opcodes/libopcodes.a  ../../libiberty/libiberty.a -lm -ldl -lnsl  -L../../zlib -lz  
libsim.a(support.o): In function `delayslot_micromips':
/usr/local/src/gnu/gdb/build/build-mips/sim/mips/../../../../sim/mips/micromips.igen:49: undefined reference to `micromips_instruction_decode'
collect2: error: ld returned 1 exit status
Makefile:340: recipe for target 'run' failed
make: *** [run] Error 1

it "worked" in the past because the default inline settings allowed for symbols to be defined in a way (duplicated) that support.o wouldn't get pulled in.  when that's fixed though, support.o gets pulled in, and this link failure is hit.
Comment 1 Maciej W. Rozycki 2016-01-12 23:45:04 UTC
Proposed fix posted here: <http://sourceware.org/ml/gdb-patches/2016-01/msg00244.html>.
Comment 2 Sourceware Commits 2016-01-18 21:50:58 UTC
The master branch has been updated by Andrew Bennett <abennett@sourceware.org>:

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

commit 3d304f48cafbff4b7a1c0a9d338fb20aa4e4934b
Author: Andrew Bennett <andrew.bennett@imgtec.com>
Date:   Mon Jan 18 21:25:19 2016 +0000

    MIPS: Only build microMIPS specific simulator functions if microMIPS support is required.
    
    This fixes PR sim/19441.  In the MIPS simulator the microMIPS
    functions in micromips.igen were not predicated on the microMIPS
    models.  This was causing build issues for some target triples.
    This patch sets all the microMIPS specific functions to only be built if
    the micromips32, micromips64 or micromipsdsp models are used.
    
    	PR sim/19441
    	* micromips.igen (delayslot_micromips): Enable for `micromips32',
    	`micromips64' and `micromipsdsp' only.
    	(process_isa_mode): Enable for `micromips32' and `micromips64' only.
    	(do_micromips_jalr, do_micromips_jal): Likewise.
    	(compute_movep_src_reg): Likewise.
    	(compute_andi16_imm): Likewise.
    	(convert_fmt_micromips): Likewise.
    	(convert_fmt_micromips_cvt_d): Likewise.
    	(convert_fmt_micromips_cvt_s): Likewise.
    	(FMT_MICROMIPS): Likewise.
    	(FMT_MICROMIPS_CVT_D): Likewise.
    	(FMT_MICROMIPS_CVT_S): Likewise.
Comment 3 Andrew Bennett 2016-01-18 21:53:07 UTC
Marking the bug as resolved.