Bug 23954 - Use of unknown relocation function causes segfault
Summary: Use of unknown relocation function causes segfault
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Jim Wilson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-05 16:08 UTC by Luís Marques
Modified: 2018-12-11 00:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2018-12-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luís Marques 2018-12-05 16:08:59 UTC
Tested with gas built from riscv-gnu-toolchain (commit 411d1345507e5313c3575720f128be9e6c0ed941, riscv-binutils commit 82dcb8613e1b1fb2989deffde1d3c9729695ff9c):

$ cat test.s
auipc x1, x0, %asdasda(foo)

$ riscv32-unknown-elf-as test.s
test.s: Assembler messages:
test.s:1: Internal error (Segmentation fault).
Please report this bug.
Comment 1 Jim Wilson 2018-12-08 01:35:56 UTC
The problem is the extra register, not the unknown relocation function.  I get the same error with just
	auipc x0, x1
The problem seems to be limited to auipc and lui, which aren't properly checking their arguments.  The second arg can be a constant or a %*hi operator, but can't be a register.  There is no check to fail when it is a register though.
Comment 2 cvs-commit@gcc.gnu.org 2018-12-11 00:42:03 UTC
The master branch has been updated by Jim Wilson <wilson@sourceware.org>:

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

commit 8970c0224e3c36c565672089e38de42765e87f47
Author: Jim Wilson <jimw@sifive.com>
Date:   Mon Dec 10 16:40:46 2018 -0800

    RISC-V: Don't segfault for two regs in auipc or lui.
    
    	gas/
    	PR gas/23954
    	* config/tc-riscv.c (my_getSmallExpression): Expand comment for
    	register support.  Set expr_end if parse a register.
    	(riscv_ip) <'u'>: Break if imm_expr is not a symbol or constant.
    	* testsuite/gas/riscv/auipc-parsing.d: New.
    	* testsuite/gas/riscv/auipc-parsing.l: New.
    	* testsuite/gas/riscv/auipc-parsing.s: New.
Comment 3 Jim Wilson 2018-12-11 00:43:46 UTC
Fixed on mainline.