Giter VIP home page Giter VIP logo

riscv-gnu-toolchain's People

Contributors

a0u avatar a4lg avatar alexsifivetw avatar aswaterman avatar cmuellner avatar colinschmidt avatar darius-bluespec avatar divan0v avatar fanghuaqi avatar ff520git avatar florianhofhammer avatar higuoxing avatar incarnation-p-lee avatar kevinpark1217 avatar kito-cheng avatar manuelafm avatar mga-sc avatar mickflemm avatar palmer-dabbelt avatar patrick-rivos avatar pz9115 avatar sbeamer avatar sickcodes avatar sorear avatar timsifive avatar tjyang avatar tommymurphytm1234 avatar vapier avatar wangpc-pp avatar yunsup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

riscv-gnu-toolchain's Issues

--enable-linux --enable-multilib is broken

I'm disabling this in the buildbot for now because I want to get automated failure emails working. This fails during stage2 GCC's install phase with a confusing libtool error that I can't figure out how to squash.

stack pointer not initialized at runtime

Maybe i'm totally wrong here, i'm not that familiar with GCC.

I'm trying to compile a simple c program for a softcore with this toolchain. By viewing the assembly/machine code i've noticed that the stack pointer starts at zero, which is undesired behaviour and makes my program crash.

By examining the default riscv.ld linker script i can see that there is a constant named _gp that is used to initialize the global pointer (gp register) in the default startup code crt0.S. But the stack pointer (sp register) is never initialized.

Did i stumble on a bug? or do i have to do something else to intialize the sp without writing my own startup code?

My toolchain is configured to use newlib and i compile my c code to RV32I machinecode.

std::bad_alloc when allocating a two std::vectors of similar sizes

This following code

#include <vector>  
#include <stdint.h>  

int main(...) {  
    std::vector<uint16_t> v0(208 * 156);  
    std::vector<uint8_t>  v1(208 * 156);  
    return 0;  
}

fails

palmer.dabbelt a5 aspire-demo-2015-summer $ riscv64-unknown-elf-g++ -std=c++11 src/broken.c++ -o out && /scratch/colins/build/riscv-tools/bin/spike /scratch/colins/build/riscv-tools/riscv64-unknown-elf/bin/pk out
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

when run on a recent GNU toolchain

palmer.dabbelt a5 riscv-tools $ git log --oneline | head -n5
fedf168 Add WFI test
212912f Fix VM, MIP encoding
5278be1 Update Linux/RISC-V boot instructions
22094ed Update to privileged architecture version 1.7
fd8e6ae Update riscv-gnu-toolchain to master

I'm assuming this is a libc bug, since odd size combinations trigger it. For example, the following allocations succeed

#include <vector>  
#include <stdint.h>  

int main(...) {  
    std::vector<uint16_t> v0(1 << 22);
    std::vector<uint8_t>  v1(1 << 1);
    return 0;  
}
#include <vector>  
#include <stdint.h>  

int main(...) {  
    std::vector<uint16_t> v0(1 << 1);
    std::vector<uint8_t>  v1(1 << 22);
    return 0;  
}

but the following fails

#include <vector>  
#include <stdint.h>  

int main(...) {  
    std::vector<uint16_t> v0(1 << 20);
    std::vector<uint8_t>  v1(1 << 20);
    return 0;  
}

I have a workaround for the demo.

Build of gcc fails in Stage 2 configure, "Unable to detect exception model."

Commands run:

./configure --prefix=/opt/riscv --enable-multilib
make linux

Output:

Checking multilib configuration for libgcc...
mkdir -p -- riscv-unknown-linux-gnu/libgcc
Configuring in riscv-unknown-linux-gnu/libgcc
configure: creating cache ./config.cache
checking build system type... x86_64-unknown-linux-gnu
checking host system type... riscv-unknown-linux-gnu
checking for --enable-version-specific-runtime-libs... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... /usr/bin/gawk
checking for riscv-unknown-linux-gnu-ar... /opt/riscv/riscv-unknown-linux-gnu/bin/ar
checking for riscv-unknown-linux-gnu-lipo... riscv-unknown-linux-gnu-lipo
checking for riscv-unknown-linux-gnu-nm... /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/nm
checking for riscv-unknown-linux-gnu-ranlib... /opt/riscv/riscv-unknown-linux-gnu/bin/ranlib
checking for riscv-unknown-linux-gnu-strip... /opt/riscv/riscv-unknown-linux-gnu/bin/strip
checking whether ln -s works... yes
checking for riscv-unknown-linux-gnu-gcc...  /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gn
u/bin/ -B/opt/riscv/riscv-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include   
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether  /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/bin/ -B/opt/riscv/riscv-u
nknown-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include    accepts -g... yes
checking for  /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/bin/ -B/opt/riscv/riscv-unkno
wn-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include    option to accept ISO C89... unsupported
checking how to run the C preprocessor...  /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/
bin/ -B/opt/riscv/riscv-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include    -E
checking size of double... 8
checking size of long double... 8
checking for inttypes.h... no
checking for stdint.h... no
checking for stdlib.h... no
checking for ftw.h... no
checking for unistd.h... no
checking for sys/stat.h... no
checking for sys/types.h... no
checking for string.h... no
checking for strings.h... no
checking for memory.h... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking whether decimal floating point is supported... no
configure: WARNING: decimal float is not supported for this target, ignored
checking whether fixed-point is supported... no
checking whether to use setjmp/longjmp exceptions... no
checking if the linker (/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/collect-ld) is GNU ld... yes
checking for thread model used by GCC... single
checking whether assembler supports CFI directives... yes
checking for target glibc version... 0.0
checking for __attribute__((visibility("hidden")))... yes
checking whether the target assembler supports thread-local storage... yes
checking whether the thread-local storage support is from emutls... no
checking for init priority support... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating auto-target.h
config.status: linking /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc/enable-execute-stack-empty.c to enable-execute-stack.c
config.status: linking /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc/unwind-generic.h to unwind.h
config.status: linking /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc/config/no-unwind.h to md-unwind-support.h
config.status: linking /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc/config/no-sfp-machine.h to sfp-machine.h
config.status: linking /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc/gthr-single.h to gthr-default.h
config.status: executing default commands
Adding multilib support to Makefile in /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/src/gcc/libgcc
multidirs=32 soft-float no-atomic soft-float/no-atomic 32/soft-float 32/no-atomic 32/soft-float/no-atomic
with_multisubdir=
Running configure in multilib subdirs 32 soft-float no-atomic soft-float/no-atomic 32/soft-float 32/no-atomic 32/soft-float/no-atomic
pwd: /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/riscv-unknown-linux-gnu/libgcc
Running configure in multilib subdir 32
pwd: /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/riscv-unknown-linux-gnu
mkdir 32
configure: creating cache ./config.cache
checking build system type... x86_64-unknown-linux-gnu
checking host system type... riscv-unknown-linux-gnu
checking for --enable-version-specific-runtime-libs... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... /usr/bin/gawk
checking for riscv-unknown-linux-gnu-ar... /opt/riscv/riscv-unknown-linux-gnu/bin/ar
checking for riscv-unknown-linux-gnu-lipo... riscv-unknown-linux-gnu-lipo
checking for riscv-unknown-linux-gnu-nm... /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/nm
checking for riscv-unknown-linux-gnu-ranlib... /opt/riscv/riscv-unknown-linux-gnu/bin/ranlib
checking for riscv-unknown-linux-gnu-strip... /opt/riscv/riscv-unknown-linux-gnu/bin/strip
checking whether ln -s works... yes
checking for riscv-unknown-linux-gnu-gcc... /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gn$
/bin/ -B/opt/riscv/riscv-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include  -m32
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/bin/ -B/opt/riscv/riscv-u$
known-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include  -m32 accepts -g... no
checking for /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/bin/ -B/opt/riscv/riscv-unkno$
n-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include  -m32 option to accept ISO C89... unsupported
checking how to run the C preprocessor... /home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/xgcc -B/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv-unknown-linux-gnu/$
in/ -B/opt/riscv/riscv-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv-unknown-linux-gnu/include -isystem /opt/riscv/riscv-unknown-linux-gnu/sys-include  -m32 -E
checking size of double... 8
checking size of long double... 8
checking for inttypes.h... no
checking for stdint.h... no
checking for stdlib.h... no
checking for ftw.h... no
checking for unistd.h... no
checking for sys/stat.h... no
checking for sys/types.h... no
checking for string.h... no
checking for strings.h... no
checking for memory.h... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking whether decimal floating point is supported... no
configure: WARNING: decimal float is not supported for this target, ignored
checking whether fixed-point is supported... no
checking whether to use setjmp/longjmp exceptions... unknown
configure: error: unable to detect exception model
Makefile:10901: recipe for target 'configure-target-libgcc' failed
make[2]: *** [configure-target-libgcc] Error 1
make[2]: Leaving directory '/home/lluixhi/git/riscv/riscv-gnu-toolchain-build/build-gcc-linux-stage1'
Makefile:143: recipe for target 'stamps/build-gcc-linux-stage1' failed
make[1]: *** [stamps/build-gcc-linux-stage1] Error 2
make[1]: Leaving directory '/home/lluixhi/git/riscv/riscv-gnu-toolchain-build'
Makefile:55: recipe for target 'linux' failed
make: *** [linux] Error 2

Unverified downloads in Makefile.in

Hi,
I noticed that the package fetching code in Makefile.in doesn't verify downloads, but immediately pipes them into tar zxf -. This creates an opportunity for man in the middle attacks, where an attacker intercepts the HTTP/FTP connections and modifies the tarballs to contain malicious files.

A simple solution would be to check every package against its known checksum (e.g. SHA256) and abort with an error message on mismatch.

[configure-target-libgcc] Error 1

I am trying to compile GCC 4.9.1 with newlib and I am getting stuck at libgcc phase.

I am configuring GCC with the following parameters:

build-gcc-newlib: build-gcc-newlib-src
rm -rf $@
mkdir $@
cd $@ &amp;&amp; $(shell pwd)/$</configure
--target=riscv-elf
--prefix=$(RELDIR)
--disable-shared
--disable-threads
--enable-tls
--enable-languages=c,c++
--with-newlib
--disable-libmudflap
--disable-libssp
--disable-libquadmath
--disable-libgomp
--disable-nls
make -C $@ -j 1 inhibit-libc=true
make -C $@ -j 1 install

At libgcc phase I get the following messages:

checking size of double... 8
checking size of long double... 8
checking whether decimal floating point is supported... no
configure: WARNING: decimal float is not supported for this target, ignored
checking whether fixed-point is supported... no
checking whether to use setjmp/longjmp exceptions... unknown
configure: error: unable to detect exception model
Makefile:11730: recipe for target 'configure-target-libgcc' failed
make[2]: *** [configure-target-libgcc] Error 1
make[2]: Leaving directory '/home/riscv_test_491/build-gcc-newlib'
Makefile:865: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/riscv_test_491/build-gcc-newlib'
Makefile:129: recipe for target 'build-gcc-newlib' failed
make: *** [build-gcc-newlib] Error 2

If I check the config.log in the build directory, and in the related libgcc directory I see the following:

configure:4222: checking whether to use setjmp/longjmp exceptions
configure:: /home/riscv_test_491/build-gcc-newlib/./gcc/xgcc -B/home/riscv_test_491/build-gcc-newlib/./gcc/ -nostdinc -B/home/riscv_test_491/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/riscv_test_491/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/riscv_test_491/build-gcc-newlib-src/newlib/libc/include -B/home/riscv_test_491/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/riscv_test_491/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/riscv_test_491/build-gcc-newlib-src/libgloss/riscv -B/home/riscv_test_491/install/riscv-elf/bin/ -B/home/riscv_test_491/install/riscv-elf/lib/ -isystem /home/riscv_test_491/install/riscv-elf/include -isystem /home/riscv_test_491/install/riscv-elf/sys-include -c --save-temps -fexceptions conftest.c >&5
conftest.c: In function 'foo':
conftest.c:19:1: error: unrecognizable insn:
}
^
(insn 10 9 11 5 (set (reg:DI 75)
(plus:DI (reg:DI 76)
(const_int -4 [0xfffffffc]))) conftest.c:17 -1
(expr_list:REG_EQUAL (const_int -4 [0xfffffffc])
(nil)))
conftest.c:19:1: internal compiler error: in extract_insn, at recog.c:2202
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.
configure:: $? = 1
configure: failed program was:
| /* confdefs.h /
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| #define SIZEOF_DOUBLE 8
| #define SIZEOF_LONG_DOUBLE 8
| #define HAVE_GETIPINFO 1
| /
end confdefs.h. */
|
| void bar ();
| void clean (int *);
| void foo ()
| {
| int i attribute ((cleanup (clean)));
| bar();
| }
|
configure:4253: result: unknown
configure:4269: error: unable to detect exception model.

What is going on here? I have my own version of a makefile for all cross-compiling process (download sources, aply patches, build binutils, build gcc with newlib) which at this point is not very clean, but I think that I can share it with anyone that wants to replicate the issue.

By the way I also had to apply the following patch to be able to compile binutils:

sed -i.bak 's_#include <execinfo.h>_/*#include <execinfo.h>*/_' ${BUILD_DIR}/binutils-${VERSION_BINUTILS}/gas/config/tc-riscv.c

Why there's an "#include <execinfo.h>" when none of its implemented functions are used in that file, and the host GCC that I am using does not have that include file?

Thanks,
Nelson

This gnu ToolChain will support 32-bit Ubuntu O S

My system configuration:
3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux.
While installing the tool chain we are getting the errors like
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
make: *** [src/original-binutils] Error 2

whether the libc support 32 bit linux programme?

when I compile a programme use the command :riscv64-unknown-linux-gnu-gcc -m32 -o test test.c
the problem:
/riscv64-unknown-linux-gnu/lib/libgcc_s.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status

shared libraries crash for at least for 32-Bit Toolchain

Hi,

I managed after some time and patches to run Linux on the RV32 architecture. However, shared libraries don't seem to work. They all crash with the same segmentation fault at the same address.
The same code compiled with --static works without problems.

Several month ago I have tried the 64-Bit toolchain with success.

Debug output:

/ # LD_DEBUG=all nano                                                           
        29:                                                                     
        29:      file=libz.so.1 [0];  needed by nano [0]                        
        29:      find library=libz.so.1 [0]; searching                          
        29:       search cache=/etc/ld.so.cache                                 
        29:       search path=/lib32/tls:/lib32:/usr/lib32/tls:/usr/lib32       
         (system search path)                                                   
        29:        trying file=/lib32/tls/libz.so.1                             
        29:        trying file=/lib32/libz.so.1                                 
        29:        trying file=/usr/lib32/tls/libz.so.1                         
[   33.810000] random: nonblocking pool is initialized                          
        29:        trying file=/usr/lib32/libz.so.1                             
        29:                                                                     
        29:      file=libz.so.1 [0];  generating link map                       
        29:        dynamic: 0x5c03a3b4  base: 0x5c023000   size: 0x00017594     
        29:          entry: 0x5c024880  phdr: 0x5c023034  phnum:          4     
        29:                                                                     
        29:                                                                     
        29:      file=libncurses.so.5 [0];  needed by nano [0]                  
        29:      find library=libncurses.so.5 [0]; searching                    
        29:       search cache=/etc/ld.so.cache                                 
        29:       search path=/lib32:/usr/lib32          (system search path)   
        29:        trying file=/lib32/libncurses.so.5                           
        29:        trying file=/usr/lib32/libncurses.so.5                       
        29:                                                                     
        29:      file=libncurses.so.5 [0];  generating link map                 
        29:        dynamic: 0x5c07c8b4  base: 0x5c03b000   size: 0x000448f4     
        29:          entry: 0x5c047ce0  phdr: 0x5c03b034  phnum:          4     
        29:                                                                     
        29:                                                                     
        29:      file=libc.so.6 [0];  needed by nano [0]                        
        29:      find library=libc.so.6 [0]; searching                          
        29:       search cache=/etc/ld.so.cache                                 
        29:       search path=/lib32:/usr/lib32          (system search path)   
        29:        trying file=/lib32/libc.so.6                                 
        29:                                                                     
        29:      file=libc.so.6 [0];  generating link map                       
        29:        dynamic: 0x5c1bff20  base: 0x5c080000   size: 0x001433f0     
        29:          entry: 0x5c097648  phdr: 0x5c080034  phnum:          9     
        29:                                                                     
        29:      checking for version `GLIBC_2.20' in file /lib32/libc.so.6 [0] 
required by file nano [0]                                                       
        29:      checking for version `GLIBC_2.20' in file /lib32/libc.so.6 [0] 
required by file /usr/lib32/libz.so.1 [0]                                       
        29:      checking for version `GLIBC_2.20' in file /lib32/libc.so.6 [0] 
required by file /usr/lib32/libncurses.so.5 [0]                                 
        29:      checking for version `GLIBC_2.20' in file /lib32/ld.so.1 [0] re
quired by file /lib32/libc.so.6 [0]                                             
        29:      checking for version `GLIBC_PRIVATE' in file /lib32/ld.so.1 [0]
 required by file /lib32/libc.so.6 [0]                                          
        29:                                                                     
        29:      Initial object scopes                                          
        29:      object=nano [0]                                                
        29:       scope 0: nano /usr/lib32/libz.so.1 /usr/lib32/libncurses.so.5 
/lib32/libc.so.6 /lib32/ld.so.1                                                 
        29:                                                                     
        29:      object=linux-vdso.so.1 [0]                                     
        29:       scope 0: nano /usr/lib32/libz.so.1 /usr/lib32/libncurses.so.5 
/lib32/libc.so.6 /lib32/ld.so.1                                                 
        29:       scope 1: linux-vdso.so.1                                      
        29:                                                                     
        29:      object=/usr/lib32/libz.so.1 [0]                                
        29:       scope 0: nano /usr/lib32/libz.so.1 /usr/lib32/libncurses.so.5 
/lib32/libc.so.6 /lib32/ld.so.1                                                 
        29:                                                                     
        29:      object=/usr/lib32/libncurses.so.5 [0]                          
        29:       scope 0: nano /usr/lib32/libz.so.1 /usr/lib32/libncurses.so.5 
/lib32/libc.so.6 /lib32/ld.so.1                                                 
        29:                                                                     
        29:      object=/lib32/libc.so.6 [0]                                    
        29:       scope 0: nano /usr/lib32/libz.so.1 /usr/lib32/libncurses.so.5 
/lib32/libc.so.6 /lib32/ld.so.1                                                 
        29:                                                                     
        29:      object=/lib32/ld.so.1 [0]                                      
        29:       no scope                                                      
        29:                                                                     
        29:                                                                     
        29:      relocation processing: /lib32/libc.so.6 (lazy)                 
        29:      symbol=_res;  lookup in file=nano [0]                          
        29:      symbol=_res;  lookup in file=/usr/lib32/libz.so.1 [0]          
        29:      symbol=_res;  lookup in file=/usr/lib32/libncurses.so.5 [0]    
        29:      symbol=_res;  lookup in file=/lib32/libc.so.6 [0]              
        29:      binding file /lib32/libc.so.6 [0] to /lib32/libc.so.6 [0]: norm
al symbol `_res' [GLIBC_2.20]                                                   
        29:      symbol=_IO_2_1_stderr_;  lookup in file=nano [0]               
        29:      symbol=_IO_2_1_stderr_;  lookup in file=/usr/lib32/libz.so.1 [0
]                                                                               
        29:      symbol=_IO_2_1_stderr_;  lookup in file=/usr/lib32/libncurses.s
o.5 [0]                                                                         
        29:      symbol=_IO_2_1_stderr_;  lookup in file=/lib32/libc.so.6 [0]   
        29:      binding file /lib32/libc.so.6 [0] to /lib32/libc.so.6 [0]: norm
al symbol `_IO_2_1_stderr_' [GLIBC_2.20]                                        
        29:      symbol=_IO_2_1_stdout_;  lookup in file=nano [0]               
        29:      symbol=_IO_2_1_stdout_;  lookup in file=/usr/lib32/libz.so.1 [0
]                                                                               
        29:      symbol=_IO_2_1_stdout_;  lookup in file=/usr/lib32/libncurses.s
o.5 [0]                                                                         
        29:      symbol=_IO_2_1_stdout_;  lookup in file=/lib32/libc.so.6 [0]   
        29:      binding file /lib32/libc.so.6 [0] to /lib32/libc.so.6 [0]: norm
al symbol `_IO_2_1_stdout_' [GLIBC_2.20]                                        
        29:      symbol=_IO_2_1_stdin_;  lookup in file=nano [0]                
        29:      symbol=_IO_2_1_stdin_;  lookup in file=/usr/lib32/libz.so.1 [0]
        29:      symbol=_IO_2_1_stdin_;  lookup in file=/usr/lib32/libncurses.so
.5 [0]                                                                          
        29:      symbol=_IO_2_1_stdin_;  lookup in file=/lib32/libc.so.6 [0]    
        29:      binding file /lib32/libc.so.6 [0] to /lib32/libc.so.6 [0]: norm
al symbol `_IO_2_1_stdin_' [GLIBC_2.20]                                         
        29:                                                                     
        29:      relocation processing: /usr/lib32/libncurses.so.5 (lazy)       
        29:      symbol=_nc_outch;  lookup in file=nano [0]                     
        29:      symbol=_nc_outch;  lookup in file=/usr/lib32/libz.so.1 [0]     
        29:      symbol=_nc_outch;  lookup in file=/usr/lib32/libncurses.so.5 [0
]                                                                               
        29:      binding file /usr/lib32/libncurses.so.5 [0] to /usr/lib32/libnc
urses.so.5 [0]: normal symbol `_nc_outch'                                       
        29:                                                                     
        29:      relocation processing: /usr/lib32/libz.so.1 (lazy)             
        29:                                                                     
        29:      relocation processing: nano (lazy)                             
        29:      symbol=curscr;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=curscr;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      binding file nano [0] to /usr/lib32/libncurses.so.5 [0]: normal
 symbol `curscr'                                                                
        29:      symbol=optarg;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=optarg;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=optarg;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `o
ptarg' [GLIBC_2.20]                                                             
        29:      symbol=stderr;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=stderr;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=stderr;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `s
tderr' [GLIBC_2.20]                                                             
        29:      symbol=stdout;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=stdout;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=stdout;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `s
tdout' [GLIBC_2.20]                                                             
        29:      symbol=COLS;  lookup in file=/usr/lib32/libz.so.1 [0]          
        29:      symbol=COLS;  lookup in file=/usr/lib32/libncurses.so.5 [0]    
        29:      binding file nano [0] to /usr/lib32/libncurses.so.5 [0]: normal
 symbol `COLS'                                                                  
        29:      symbol=stdscr;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=stdscr;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      binding file nano [0] to /usr/lib32/libncurses.so.5 [0]: normal
 symbol `stdscr'                                                                
        29:      symbol=optind;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=optind;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=optind;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `o
ptind' [GLIBC_2.20]                                                             
        29:      symbol=stdin;  lookup in file=/usr/lib32/libz.so.1 [0]         
        29:      symbol=stdin;  lookup in file=/usr/lib32/libncurses.so.5 [0]   
        29:      symbol=stdin;  lookup in file=/lib32/libc.so.6 [0]             
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `s
tdin' [GLIBC_2.20]                                                              
        29:      symbol=LINES;  lookup in file=/usr/lib32/libz.so.1 [0]         
        29:      symbol=LINES;  lookup in file=/usr/lib32/libncurses.so.5 [0]   
        29:      binding file nano [0] to /usr/lib32/libncurses.so.5 [0]: normal
 symbol `LINES'                                                                 
        29:                                                                     
        29:      relocation processing: /lib32/ld.so.1                          
        29:      symbol=malloc;  lookup in file=nano [0]                        
        29:      symbol=malloc;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=malloc;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=malloc;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file /lib32/ld.so.1 [0] to /lib32/libc.so.6 [0]: normal
 symbol `malloc' [GLIBC_2.20]                                                   
        29:      symbol=calloc;  lookup in file=nano [0]                        
        29:      symbol=calloc;  lookup in file=/usr/lib32/libz.so.1 [0]        
        29:      symbol=calloc;  lookup in file=/usr/lib32/libncurses.so.5 [0]  
        29:      symbol=calloc;  lookup in file=/lib32/libc.so.6 [0]            
        29:      binding file /lib32/ld.so.1 [0] to /lib32/libc.so.6 [0]: normal
 symbol `calloc' [GLIBC_2.20]                                                   
        29:      symbol=free;  lookup in file=nano [0]                          
        29:      symbol=free;  lookup in file=/usr/lib32/libz.so.1 [0]          
        29:      symbol=free;  lookup in file=/usr/lib32/libncurses.so.5 [0]    
        29:      symbol=free;  lookup in file=/lib32/libc.so.6 [0]              
        29:      binding file /lib32/ld.so.1 [0] to /lib32/libc.so.6 [0]: normal
 symbol `free' [GLIBC_2.20]                                                     
        29:                                                                     
        29:      calling init: /lib32/libc.so.6                                 
        29:                                                                     
        29:                                                                     
        29:      calling init: /usr/lib32/libncurses.so.5                       
        29:                                                                     
        29:                                                                     
        29:      calling init: /usr/lib32/libz.so.1                             
        29:                                                                     
        29:      symbol=__libc_start_main;  lookup in file=nano [0]             
        29:      symbol=__libc_start_main;  lookup in file=/usr/lib32/libz.so.1 
[0]                                                                             
        29:      symbol=__libc_start_main;  lookup in file=/usr/lib32/libncurses
.so.5 [0]                                                                       
        29:      symbol=__libc_start_main;  lookup in file=/lib32/libc.so.6 [0] 
        29:      binding file nano [0] to /lib32/libc.so.6 [0]: normal symbol `_
_libc_start_main' [GLIBC_2.20]                                                  
[  127.820000] nano[29]: unhandled signal 11 code 0x30001 at 0x02c79c62 in ld-2.
21.so[5c000000+1e000]                                                           
[  127.820000] CPU: 0 PID: 29 Comm: nano Not tainted 4.1.2-g9eb60e4-dirty #4    
[  127.820000] task: c1492060 ti: c1584000 task.ti: c1584000                    
[  127.820000] sepc: 02c79c62 ra : 5c097544 sp : b7ddddc0                       
[  127.820000]  gp : 00822b50 tp : 5c1c44a0 t0 : 5c097444                       
[  127.820000]  t1 : 5c0accb8 t2 : 00000020 s0 : 0081c84c                       
[  127.830000]  s1 : 00000002 a0 : 5c192088 a1 : b7dddf89                       
[  127.830000]  a2 : 00000001 a3 : 00000001 a4 : b7dddeb4                       
[  127.830000]  a5 : 02c79c63 a6 : 5c1c0f6c a7 : 00000000                       
[  127.830000]  s2 : 009cf9ad s3 : 009962bc s4 : 009e955c                       
[  127.830000]  s5 : 009e84b8 s6 : 00000008 s7 : 00000014                       
[  127.830000]  s8 : 009e7000 s9 : 00000000 s10: 0099f8b4                       
[  127.830000]  s11: ffffffff t3 : ffffffff t4 : b7dddad4                       
[  127.840000]  t5 : 00000040 t6 : 5c021018                                     
[  127.840000] sstatus: 00003008 sbadaddr: 02c79c62 scause: 00000001            
Segmentation fault            

R_RISCV_COPY relocs and functions

It looks like gcc or ld is no idea about type of some symbols (see linker warnings below) and it emits R_RISCV_COPY relocations for it. But the symbols are functions (!). We don't expect that functions body can be relocated.

$ pwd
/home/rb743/obj/riscv.riscv/home/rb743/dev/freebsd-riscv/bin/ls
$ 
$ /home/rb743/opt/sptbr/bin/riscv64-unknown-freebsd11.0-gcc -isystem /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/include -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib --sysroot=/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp  -O2 -pipe   -DCOLORLS  -std=gnu99 -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-error=unused-function -Wno-error=enum-compare -Wno-error=logical-not-parentheses -Wno-error=bool-compare -Wno-error=uninitialized -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=cast-align -Wno-error=extra -Wno-error=attributes -Wno-error=inline -Wno-error=unused-but-set-variable -Wno-error=unused-value -Wno-error=strict-aliasing -Wno-error=address    -o ls cmp.o ls.o print.o util.o  -lxo  -lutil  -ltermcapw
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `_kill@@FBSDprivate_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `_getpid@@FBSDprivate_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `_getuid@@FBSDprivate_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `_readlink@@FBSDprivate_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `ioctl@@FBSD_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `kill@@FBSD_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `lpathconf@@FBSD_1.1' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `getuid@@FBSD_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `readlink@@FBSD_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `_ioctl@@FBSDprivate_1.0' are not defined
/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: warning: type and size of dynamic symbol `getpid@@FBSD_1.0' are not defined
$ 
$ 
$ /home/rb743/opt/sptbr/bin/riscv64-unknown-freebsd11.0-gcc -isystem /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/include -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib --sysroot=/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp  -O2 -pipe   -DCOLORLS  -std=gnu99 -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-error=unused-function -Wno-error=enum-compare -Wno-error=logical-not-parentheses -Wno-error=bool-compare -Wno-error=uninitialized -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=cast-align -Wno-error=extra -Wno-error=attributes -Wno-error=inline -Wno-error=unused-but-set-variable -Wno-error=unused-value -Wno-error=strict-aliasing -Wno-error=address    -o ls cmp.o ls.o print.o util.o  -lxo  -lutil  -ltermcapw -###
Using built-in specs.
COLLECT_GCC=/home/rb743/opt/sptbr/bin/riscv64-unknown-freebsd11.0-gcc
COLLECT_LTO_WRAPPER=/home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/lto-wrapper
Target: riscv64-unknown-freebsd11.0
Configured with: /home/rb743/dev/freebsd-riscv-gnu-toolchain-sptbr/src/gcc/configure --target=riscv64-unknown-freebsd11.0 --prefix=/home/rb743/opt/sptbr --with-sysroot=/home/rb743/opt/sptbr/sysroot --without-newlib --without-headers --disable-shared --disable-threads --enable-tls --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --disable-libatomic --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-multilib --disable-bootstrap
Thread model: single
gcc version 5.2.0 (GCC) 
COMPILER_PATH=/home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/:/home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/:/home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/:/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/:/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/:/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/bin/
LIBRARY_PATH=/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/:/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/lib/../lib/:/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/lib/../lib/:/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/:/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/lib/:/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/lib/:/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/
COLLECT_GCC_OPTIONS='-isystem' '/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/include' '-L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib' '-O2' '-pipe' '-D' 'COLORLS' '-std=gnu99' '-fstack-protector-strong' '-Wsystem-headers' '-Werror' '-Wall' '-Wno-format-y2k' '-Wextra' '-Wstrict-prototypes' '-Wmissing-prototypes' '-Wpointer-arith' '-Wreturn-type' '-Wcast-qual' '-Wwrite-strings' '-Wswitch' '-Wshadow' '-Wunused-parameter' '-Wcast-align' '-Wchar-subscripts' '-Winline' '-Wnested-externs' '-Wredundant-decls' '-Wold-style-definition' '-Wno-pointer-sign' '-Wno-error=unused-function' '-Wno-error=enum-compare' '-Wno-error=logical-not-parentheses' '-Wno-error=bool-compare' '-Wno-error=uninitialized' '-Wno-error=array-bounds' '-Wno-error=clobbered' '-Wno-error=cast-align' '-Wno-error=extra' '-Wno-error=attributes' '-Wno-error=inline' '-Wno-error=unused-but-set-variable' '-Wno-error=unused-value' '-Wno-error=strict-aliasing' '-Wno-error=address' '-o' 'ls'
 /home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/collect2 -plugin /home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/liblto_plugin.so "-plugin-opt=/home/rb743/opt/sptbr/libexec/gcc/riscv64-unknown-freebsd11.0/5.2.0/lto-wrapper" "-plugin-opt=-fresolution=/tmp//ccK9vr17.res" "-plugin-opt=-pass-through=-lgcc" "-plugin-opt=-pass-through=-lc" "-plugin-opt=-pass-through=-lgcc" "--sysroot=/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 -melf64lriscv -o ls /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/crt1.o /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/crti.o /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/crtbegin.o -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib -L/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0 -L/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/lib/../lib -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/lib/../lib -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib -L/home/rb743/opt/sptbr/lib/gcc/riscv64-unknown-freebsd11.0/5.2.0/../../../../riscv64-unknown-freebsd11.0/lib -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/lib -L/home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib cmp.o ls.o print.o util.o -lxo -lutil -ltermcapw -lssp_nonshared -lgcc -lc -lgcc /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/crtend.o /home/rb743/obj//riscv.riscv/home/rb743/dev/freebsd-riscv/tmp/usr/lib/../lib/crtn.o
$ 
$ ~/opt/sptbr/bin/riscv64-unknown-freebsd11.0-readelf -a ls
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           RISC-V
  Version:                           0x1
  Entry point address:               0x80343c
  Start of program headers:          64 (bytes into file)
  Start of section headers:          36072 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         30
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         00000000008001c8  000001c8
       0000000000000015  0000000000000000   A       0     0     1
  [ 2] .note.tag         NOTE             00000000008001e0  000001e0
       0000000000000030  0000000000000000   A       0     0     4
  [ 3] .hash             HASH             0000000000800210  00000210
       0000000000000318  0000000000000004   A       4     0     8
  [ 4] .dynsym           DYNSYM           0000000000800528  00000528
       0000000000000948  0000000000000018   A       5     1     8
  [ 5] .dynstr           STRTAB           0000000000800e70  00000e70
       000000000000040c  0000000000000000   A       0     0     1
  [ 6] .gnu.version      VERSYM           000000000080127c  0000127c
       00000000000000c6  0000000000000002   A       4     0     2
  [ 7] .gnu.version_r    VERNEED          0000000000801348  00001348
       0000000000000050  0000000000000000   A       5     1     8
  [ 8] .rela.dyn         RELA             0000000000801398  00001398
       0000000000000120  0000000000000018   A       4     0     8
  [ 9] .rela.plt         RELA             00000000008014b8  000014b8
       0000000000000690  0000000000000018  AI       4    11     8
  [10] .init             PROGBITS         0000000000801b50  00001b50
       0000000000000014  0000000000000000  AX       0     0     16
  [11] .plt              PROGBITS         0000000000801b70  00001b70
       0000000000000480  0000000000000010  AX       0     0     16
  [12] .text             PROGBITS         0000000000801ff0  00001ff0
       00000000000039d8  0000000000000000  AX       0     0     4
  [13] .fini             PROGBITS         00000000008059d0  000059d0
       0000000000000014  0000000000000000  AX       0     0     16
  [14] .rodata           PROGBITS         00000000008059e8  000059e8
       0000000000000830  0000000000000000   A       0     0     8
  [15] .init_array       INIT_ARRAY       0000000000807218  00006218
       0000000000000008  0000000000000000  WA       0     0     8
  [16] .fini_array       FINI_ARRAY       0000000000807220  00006220
       0000000000000008  0000000000000000  WA       0     0     8
  [17] .ctors            PROGBITS         0000000000807228  00006228
       0000000000000010  0000000000000000  WA       0     0     8
  [18] .dtors            PROGBITS         0000000000807238  00006238
       0000000000000010  0000000000000000  WA       0     0     8
  [19] .jcr              PROGBITS         0000000000807248  00006248
       0000000000000008  0000000000000000  WA       0     0     8
  [20] .dynamic          DYNAMIC          0000000000807250  00006250
       0000000000000200  0000000000000010  WA       5     0     8
  [21] .data             PROGBITS         0000000000807450  00006450
       0000000000000010  0000000000000000  WA       0     0     8
  [22] .got              PROGBITS         0000000000807460  00006460
       0000000000000248  0000000000000008  WA       0     0     8
  [23] .sdata            PROGBITS         00000000008076a8  000066a8
       000000000000002c  0000000000000000  WA       0     0     8
  [24] .sbss             NOBITS           00000000008076d8  000066d4
       0000000000000060  0000000000000000  WA       0     0     8
  [25] .bss              NOBITS           0000000000807738  000066d4
       0000000000001280  0000000000000000  WA       0     0     8
  [26] .comment          PROGBITS         0000000000000000  000066d4
       00000000000000b1  0000000000000001  MS       0     0     1
  [27] .shstrtab         STRTAB           0000000000000000  00006785
       00000000000000e7  0000000000000000           0     0     1
  [28] .symtab           SYMTAB           0000000000000000  00006870
       0000000000001800  0000000000000018          29   100     8
  [29] .strtab           STRTAB           0000000000000000  00008070
       0000000000000c78  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000800040 0x0000000000800040
                 0x0000000000000188 0x0000000000000188  R E    8
  INTERP         0x00000000000001c8 0x00000000008001c8 0x00000000008001c8
                 0x0000000000000015 0x0000000000000015  R      1
      [Requesting program interpreter: /libexec/ld-elf.so.1]
  LOAD           0x0000000000000000 0x0000000000800000 0x0000000000800000
                 0x0000000000006218 0x0000000000006218  R E    1000
  LOAD           0x0000000000006218 0x0000000000807218 0x0000000000807218
                 0x00000000000004bc 0x00000000000017a0  RW     1000
  DYNAMIC        0x0000000000006250 0x0000000000807250 0x0000000000807250
                 0x0000000000000200 0x0000000000000200  RW     8
  NOTE           0x00000000000001e0 0x00000000008001e0 0x00000000008001e0
                 0x0000000000000030 0x0000000000000030  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     10

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata 
   03     .init_array .fini_array .ctors .dtors .jcr .dynamic .data .got .sdata .sbss .bss 
   04     .dynamic 
   05     .note.tag 
   06     

Dynamic section at offset 0x6250 contains 27 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libxo.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libutil.so.9]
 0x0000000000000001 (NEEDED)             Shared library: [libncursesw.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
 0x000000000000000c (INIT)               0x801b50
 0x000000000000000d (FINI)               0x8059d0
 0x0000000000000019 (INIT_ARRAY)         0x807218
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x807220
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x0000000000000004 (HASH)               0x800210
 0x0000000000000005 (STRTAB)             0x800e70
 0x0000000000000006 (SYMTAB)             0x800528
 0x000000000000000a (STRSZ)              1036 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x807460
 0x0000000000000002 (PLTRELSZ)           1680 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x8014b8
 0x0000000000000007 (RELA)               0x801398
 0x0000000000000008 (RELASZ)             1968 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x801348
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x80127c
 0x0000000000000000 (NULL)               0x0

Relocation section '.rela.dyn' at offset 0x1398 contains 12 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000807738  000700000004 R_RISCV_COPY      0000000000807738 optind + 0
000000807740  000800000004 R_RISCV_COPY      0000000000807740 _DefaultRuneLocale + 0
0000008087c0  000d00000004 R_RISCV_COPY      00000000008087c0 _CurrentRuneLocale + 0
0000008087c8  001000000004 R_RISCV_COPY      00000000008087c8 __stack_chk_guard + 0
000000808808  001500000004 R_RISCV_COPY      0000000000808808 __mb_sb_limit + 0
00000080880c  001900000004 R_RISCV_COPY      000000000080880c __sys_kill + 0
000000808820  001d00000004 R_RISCV_COPY      0000000000808820 __sys_getuid + 0
000000808838  004f00000004 R_RISCV_COPY      0000000000808838 __sys_getpid + 0
000000808850  002e00000004 R_RISCV_COPY      0000000000808850 optarg + 0
000000808858  004800000004 R_RISCV_COPY      0000000000808858 __sys_readlink + 0
00000080886c  006100000004 R_RISCV_COPY      000000000080886c __sys_ioctl + 0
000000808880  005f00000004 R_RISCV_COPY      0000000000001668 _ThreadRuneLocale + 0

Relocation section '.rela.plt' at offset 0x14b8 contains 70 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000807470  000100000005 R_RISCV_JUMP_SLOT 0000000000801b90 fts_open + 0
000000807478  000200000005 R_RISCV_JUMP_SLOT 0000000000801ba0 localtime + 0
000000807480  000300000005 R_RISCV_JUMP_SLOT 0000000000801bb0 fts_set + 0
000000807488  000400000005 R_RISCV_JUMP_SLOT 0000000000801bc0 getenv + 0
000000807490  000500000005 R_RISCV_JUMP_SLOT 0000000000801bd0 sscanf + 0
000000807498  000600000005 R_RISCV_JUMP_SLOT 0000000000801be0 atexit + 0
0000008074a0  000900000005 R_RISCV_JUMP_SLOT 0000000000801bf0 xo_finish + 0
0000008074a8  000a00000005 R_RISCV_JUMP_SLOT 0000000000801c00 write + 0
0000008074b0  000b00000005 R_RISCV_JUMP_SLOT 0000000000801c10 tputs + 0
0000008074b8  000c00000005 R_RISCV_JUMP_SLOT 0000000000801c20 xo_error + 0
0000008074c0  000e00000005 R_RISCV_JUMP_SLOT 0000000000801c30 signal + 0
0000008074c8  000f00000005 R_RISCV_JUMP_SLOT 0000000000801c40 setlocale + 0
0000008074d0  001100000005 R_RISCV_JUMP_SLOT 0000000000801c50 strtonum + 0
0000008074d8  001300000005 R_RISCV_JUMP_SLOT 0000000000801c60 __error + 0
0000008074e0  001600000005 R_RISCV_JUMP_SLOT 0000000000801c70 tgoto + 0
0000008074e8  001700000005 R_RISCV_JUMP_SLOT 0000000000801c80 strlen + 0
0000008074f0  001800000005 R_RISCV_JUMP_SLOT 0000000000801c90 setenv + 0
0000008074f8  001a00000005 R_RISCV_JUMP_SLOT 0000000000801ca0 acl_is_trivial_np + 0
000000807500  001b00000005 R_RISCV_JUMP_SLOT 0000000000801cb0 free + 0
000000807508  001c00000005 R_RISCV_JUMP_SLOT 0000000000801cc0 xo_open_container + 0
000000807510  001e00000005 R_RISCV_JUMP_SLOT 0000000000801cd0 mbrtowc + 0
000000807518  001f00000005 R_RISCV_JUMP_SLOT 0000000000801ce0 fts_read + 0
000000807520  002100000005 R_RISCV_JUMP_SLOT 0000000000801cf0 strchr + 0
000000807528  002300000005 R_RISCV_JUMP_SLOT 0000000000801d00 group_from_gid + 0
000000807530  002400000005 R_RISCV_JUMP_SLOT 0000000000801d10 xo_warnx + 0
000000807538  002500000005 R_RISCV_JUMP_SLOT 0000000000801d20 user_from_uid + 0
000000807540  002600000005 R_RISCV_JUMP_SLOT 0000000000801d30 strcpy + 0
000000807548  002800000005 R_RISCV_JUMP_SLOT 0000000000801d40 nl_langinfo + 0
000000807550  002900000005 R_RISCV_JUMP_SLOT 0000000000801d50 xo_emit + 0
000000807558  002a00000005 R_RISCV_JUMP_SLOT 0000000000801d60 tgetent + 0
000000807560  002b00000005 R_RISCV_JUMP_SLOT 0000000000801d70 snprintf + 0
000000807568  002c00000005 R_RISCV_JUMP_SLOT 0000000000801d80 memset + 0
000000807570  002d00000005 R_RISCV_JUMP_SLOT 0000000000801d90 fts_children + 0
000000807578  002f00000005 R_RISCV_JUMP_SLOT 0000000000801da0 getopt + 0
000000807580  003000000005 R_RISCV_JUMP_SLOT 0000000000801db0 realloc + 0
000000807588  003100000005 R_RISCV_JUMP_SLOT 0000000000801dc0 mac_free + 0
000000807590  003200000005 R_RISCV_JUMP_SLOT 0000000000801dd0 xo_attr + 0
000000807598  003300000005 R_RISCV_JUMP_SLOT 0000000000801de0 mac_get_link + 0
0000008075a0  003400000005 R_RISCV_JUMP_SLOT 0000000000801df0 xo_set_version + 0
0000008075a8  003500000005 R_RISCV_JUMP_SLOT 0000000000801e00 strftime + 0
0000008075b0  003600000005 R_RISCV_JUMP_SLOT 0000000000801e10 acl_get_link_np + 0
0000008075b8  003700000005 R_RISCV_JUMP_SLOT 0000000000801e20 fflagstostr + 0
0000008075c0  003900000005 R_RISCV_JUMP_SLOT 0000000000801e30 strerror + 0
0000008075c8  003a00000005 R_RISCV_JUMP_SLOT 0000000000801e40 xo_err + 0
0000008075d0  003b00000005 R_RISCV_JUMP_SLOT 0000000000801e50 ___runetype + 0
0000008075d8  003c00000005 R_RISCV_JUMP_SLOT 0000000000801e60 xo_close_list + 0
0000008075e0  003d00000005 R_RISCV_JUMP_SLOT 0000000000801e70 strmode + 0
0000008075e8  003e00000005 R_RISCV_JUMP_SLOT 0000000000801e80 xo_set_flags + 0
0000008075f0  003f00000005 R_RISCV_JUMP_SLOT 0000000000801e90 xo_open_list + 0
0000008075f8  004100000005 R_RISCV_JUMP_SLOT 0000000000801ea0 xo_open_instance + 0
000000807600  004300000005 R_RISCV_JUMP_SLOT 0000000000801eb0 exit + 0
000000807608  004400000005 R_RISCV_JUMP_SLOT 0000000000801ec0 time + 0
000000807610  004600000005 R_RISCV_JUMP_SLOT 0000000000801ed0 mac_get_file + 0
000000807618  004b00000005 R_RISCV_JUMP_SLOT 0000000000801ee0 asprintf + 0
000000807620  004c00000005 R_RISCV_JUMP_SLOT 0000000000801ef0 __stack_chk_fail + 0
000000807628  004e00000005 R_RISCV_JUMP_SLOT 0000000000801f00 getbsize + 0
000000807630  005000000005 R_RISCV_JUMP_SLOT 0000000000801f10 mac_prepare_file_label + 0
000000807638  005100000005 R_RISCV_JUMP_SLOT 0000000000801f20 strcoll + 0
000000807640  005300000005 R_RISCV_JUMP_SLOT 0000000000801f30 tgetstr + 0
000000807648  005400000005 R_RISCV_JUMP_SLOT 0000000000801f40 xo_parse_args + 0
000000807650  005500000005 R_RISCV_JUMP_SLOT 0000000000801f50 xo_warn + 0
000000807658  005600000005 R_RISCV_JUMP_SLOT 0000000000801f60 isatty + 0
000000807660  005800000005 R_RISCV_JUMP_SLOT 0000000000801f70 mac_to_text + 0
000000807668  005900000005 R_RISCV_JUMP_SLOT 0000000000801f80 xo_close_instance + 0
000000807670  005a00000005 R_RISCV_JUMP_SLOT 0000000000801f90 xo_close_container + 0
000000807678  005b00000005 R_RISCV_JUMP_SLOT 0000000000801fa0 strdup + 0
000000807680  005c00000005 R_RISCV_JUMP_SLOT 0000000000801fb0 acl_free + 0
000000807688  005d00000005 R_RISCV_JUMP_SLOT 0000000000801fc0 malloc + 0
000000807690  006000000005 R_RISCV_JUMP_SLOT 0000000000801fd0 _init_tls + 0
000000807698  006200000005 R_RISCV_JUMP_SLOT 0000000000801fe0 humanize_number + 0

The decoding of unwind sections for machine type RISC-V is not currently supported.

Symbol table '.dynsym' contains 99 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000801b90     0 FUNC    GLOBAL DEFAULT  UND fts_open@FBSD_1.1 (2)
     2: 0000000000801ba0     0 FUNC    GLOBAL DEFAULT  UND localtime@FBSD_1.0 (3)
     3: 0000000000801bb0     0 FUNC    GLOBAL DEFAULT  UND fts_set@FBSD_1.1 (2)
     4: 0000000000801bc0     0 FUNC    GLOBAL DEFAULT  UND getenv@FBSD_1.0 (3)
     5: 0000000000801bd0     0 FUNC    GLOBAL DEFAULT  UND sscanf@FBSD_1.0 (3)
     6: 0000000000801be0     0 FUNC    GLOBAL DEFAULT  UND atexit@FBSD_1.0 (3)
     7: 0000000000807738     4 OBJECT  GLOBAL DEFAULT   25 optind@FBSD_1.0 (3)
     8: 0000000000807740  4224 OBJECT  GLOBAL DEFAULT   25 _DefaultRuneLocale@FBSD_1.0 (3)
     9: 0000000000801bf0     0 FUNC    GLOBAL DEFAULT  UND xo_finish
    10: 0000000000801c00     0 FUNC    GLOBAL DEFAULT  UND write@FBSD_1.0 (3)
    11: 0000000000801c10     0 FUNC    GLOBAL DEFAULT  UND tputs
    12: 0000000000801c20     0 FUNC    GLOBAL DEFAULT  UND xo_error
    13: 00000000008087c0     8 OBJECT  GLOBAL DEFAULT   25 _CurrentRuneLocale@FBSD_1.0 (3)
    14: 0000000000801c30     0 FUNC    GLOBAL DEFAULT  UND signal@FBSD_1.0 (3)
    15: 0000000000801c40     0 FUNC    GLOBAL DEFAULT  UND setlocale@FBSD_1.0 (3)
    16: 00000000008087c8    64 OBJECT  GLOBAL DEFAULT   25 __stack_chk_guard@FBSD_1.0 (3)
    17: 0000000000801c50     0 FUNC    GLOBAL DEFAULT  UND strtonum@FBSD_1.0 (3)
    18: 00000000008076d4     0 NOTYPE  GLOBAL DEFAULT   23 _edata
    19: 0000000000801c60     0 FUNC    GLOBAL DEFAULT  UND __error@FBSD_1.0 (3)
    20: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND sp
    21: 0000000000808808     4 OBJECT  GLOBAL DEFAULT   25 __mb_sb_limit@FBSD_1.0 (3)
    22: 0000000000801c70     0 FUNC    GLOBAL DEFAULT  UND tgoto
    23: 0000000000801c80     0 FUNC    GLOBAL DEFAULT  UND strlen@FBSD_1.0 (3)
    24: 0000000000801c90     0 FUNC    GLOBAL DEFAULT  UND setenv@FBSD_1.0 (3)
    25: 000000000080880c    20 NOTYPE  GLOBAL DEFAULT   25 __sys_kill@FBSDprivate_1.0 (4)
    26: 0000000000801ca0     0 FUNC    GLOBAL DEFAULT  UND acl_is_trivial_np@FBSD_1.1 (2)
    27: 0000000000801cb0     0 FUNC    GLOBAL DEFAULT  UND free@FBSD_1.0 (3)
    28: 0000000000801cc0     0 FUNC    GLOBAL DEFAULT  UND xo_open_container
    29: 0000000000808820    20 NOTYPE  GLOBAL DEFAULT   25 __sys_getuid@FBSDprivate_1.0 (4)
    30: 0000000000801cd0     0 FUNC    GLOBAL DEFAULT  UND mbrtowc@FBSD_1.0 (3)
    31: 0000000000801ce0     0 FUNC    GLOBAL DEFAULT  UND fts_read@FBSD_1.1 (2)
    32: 000000000080880c     0 NOTYPE  WEAK   DEFAULT   25 _kill@FBSDprivate_1.0 (4)
    33: 0000000000801cf0     0 FUNC    GLOBAL DEFAULT  UND strchr@FBSD_1.0 (3)
    34: 0000000000808838     0 NOTYPE  WEAK   DEFAULT   25 _getpid@FBSDprivate_1.0 (4)
    35: 0000000000801d00     0 FUNC    GLOBAL DEFAULT  UND group_from_gid@FBSD_1.0 (3)
    36: 0000000000801d10     0 FUNC    GLOBAL DEFAULT  UND xo_warnx
    37: 0000000000801d20     0 FUNC    GLOBAL DEFAULT  UND user_from_uid@FBSD_1.0 (3)
    38: 0000000000801d30     0 FUNC    GLOBAL DEFAULT  UND strcpy@FBSD_1.0 (3)
    39: 0000000000808918     8 OBJECT  GLOBAL DEFAULT   25 environ
    40: 0000000000801d40     0 FUNC    GLOBAL DEFAULT  UND nl_langinfo@FBSD_1.0 (3)
    41: 0000000000801d50     0 FUNC    GLOBAL DEFAULT  UND xo_emit
    42: 0000000000801d60     0 FUNC    GLOBAL DEFAULT  UND tgetent
    43: 0000000000801d70     0 FUNC    GLOBAL DEFAULT  UND snprintf@FBSD_1.0 (3)
    44: 0000000000801d80     0 FUNC    GLOBAL DEFAULT  UND memset@FBSD_1.0 (3)
    45: 0000000000801d90     0 FUNC    GLOBAL DEFAULT  UND fts_children@FBSD_1.1 (2)
    46: 0000000000808850     8 OBJECT  GLOBAL DEFAULT   25 optarg@FBSD_1.0 (3)
    47: 0000000000801da0     0 FUNC    GLOBAL DEFAULT  UND getopt@FBSD_1.0 (3)
    48: 0000000000801db0     0 FUNC    GLOBAL DEFAULT  UND realloc@FBSD_1.0 (3)
    49: 0000000000801dc0     0 FUNC    GLOBAL DEFAULT  UND mac_free@FBSD_1.0 (3)
    50: 0000000000801dd0     0 FUNC    GLOBAL DEFAULT  UND xo_attr
    51: 0000000000801de0     0 FUNC    GLOBAL DEFAULT  UND mac_get_link@FBSD_1.0 (3)
    52: 0000000000801df0     0 FUNC    GLOBAL DEFAULT  UND xo_set_version
    53: 0000000000801e00     0 FUNC    GLOBAL DEFAULT  UND strftime@FBSD_1.0 (3)
    54: 0000000000801e10     0 FUNC    GLOBAL DEFAULT  UND acl_get_link_np@FBSD_1.0 (3)
    55: 0000000000801e20     0 FUNC    GLOBAL DEFAULT  UND fflagstostr@FBSD_1.0 (3)
    56: 0000000000808820     0 NOTYPE  WEAK   DEFAULT   25 _getuid@FBSDprivate_1.0 (4)
    57: 0000000000801e30     0 FUNC    GLOBAL DEFAULT  UND strerror@FBSD_1.0 (3)
    58: 0000000000801e40     0 FUNC    GLOBAL DEFAULT  UND xo_err
    59: 0000000000801e50     0 FUNC    GLOBAL DEFAULT  UND ___runetype@FBSD_1.0 (3)
    60: 0000000000801e60     0 FUNC    GLOBAL DEFAULT  UND xo_close_list
    61: 0000000000801e70     0 FUNC    GLOBAL DEFAULT  UND strmode@FBSD_1.0 (3)
    62: 0000000000801e80     0 FUNC    GLOBAL DEFAULT  UND xo_set_flags
    63: 0000000000801e90     0 FUNC    GLOBAL DEFAULT  UND xo_open_list
    64: 00000000008089b8     0 NOTYPE  GLOBAL DEFAULT   25 _end
    65: 0000000000801ea0     0 FUNC    GLOBAL DEFAULT  UND xo_open_instance
    66: 000000000080886c     0 NOTYPE  WEAK   DEFAULT   25 ioctl@FBSD_1.0 (3)
    67: 0000000000801eb0     0 FUNC    GLOBAL DEFAULT  UND exit@FBSD_1.0 (3)
    68: 0000000000801ec0     0 FUNC    GLOBAL DEFAULT  UND time@FBSD_1.0 (3)
    69: 000000000080880c     0 NOTYPE  WEAK   DEFAULT   25 kill@FBSD_1.0 (3)
    70: 0000000000801ed0     0 FUNC    GLOBAL DEFAULT  UND mac_get_file@FBSD_1.0 (3)
    71: 00000000008076d4     0 NOTYPE  GLOBAL DEFAULT   24 __bss_start
    72: 0000000000808858    20 NOTYPE  GLOBAL DEFAULT   25 __sys_readlink@FBSDprivate_1.0 (4)
    73: 0000000000808880     0 NOTYPE  WEAK   DEFAULT   25 lpathconf@FBSD_1.1 (2)
    74: 0000000000808820     0 NOTYPE  WEAK   DEFAULT   25 getuid@FBSD_1.0 (3)
    75: 0000000000801ee0     0 FUNC    GLOBAL DEFAULT  UND asprintf@FBSD_1.0 (3)
    76: 0000000000801ef0     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@FBSD_1.0 (3)
    77: 0000000000808858     0 NOTYPE  WEAK   DEFAULT   25 readlink@FBSD_1.0 (3)
    78: 0000000000801f00     0 FUNC    GLOBAL DEFAULT  UND getbsize@FBSD_1.0 (3)
    79: 0000000000808838    20 NOTYPE  GLOBAL DEFAULT   25 __sys_getpid@FBSDprivate_1.0 (4)
    80: 0000000000801f10     0 FUNC    GLOBAL DEFAULT  UND mac_prepare_file_label@FBSD_1.0 (3)
    81: 0000000000801f20     0 FUNC    GLOBAL DEFAULT  UND strcoll@FBSD_1.0 (3)
    82: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
    83: 0000000000801f30     0 FUNC    GLOBAL DEFAULT  UND tgetstr
    84: 0000000000801f40     0 FUNC    GLOBAL DEFAULT  UND xo_parse_args
    85: 0000000000801f50     0 FUNC    GLOBAL DEFAULT  UND xo_warn
    86: 0000000000801f60     0 FUNC    GLOBAL DEFAULT  UND isatty@FBSD_1.0 (3)
    87: 0000000000808838     0 NOTYPE  WEAK   DEFAULT   25 getpid@FBSD_1.0 (3)
    88: 0000000000801f70     0 FUNC    GLOBAL DEFAULT  UND mac_to_text@FBSD_1.0 (3)
    89: 0000000000801f80     0 FUNC    GLOBAL DEFAULT  UND xo_close_instance
    90: 0000000000801f90     0 FUNC    GLOBAL DEFAULT  UND xo_close_container
    91: 0000000000801fa0     0 FUNC    GLOBAL DEFAULT  UND strdup@FBSD_1.0 (3)
    92: 0000000000801fb0     0 FUNC    GLOBAL DEFAULT  UND acl_free@FBSD_1.0 (3)
    93: 0000000000801fc0     0 FUNC    GLOBAL DEFAULT  UND malloc@FBSD_1.0 (3)
    94: 00000000008076a8     8 OBJECT  GLOBAL DEFAULT   23 __progname
    95: 0000000000001668     8 TLS     GLOBAL DEFAULT   25 _ThreadRuneLocale@FBSD_1.3 (5)
    96: 0000000000801fd0     0 FUNC    GLOBAL DEFAULT  UND _init_tls@FBSD_1.0 (3)
    97: 000000000080886c    20 NOTYPE  GLOBAL DEFAULT   25 __sys_ioctl@FBSDprivate_1.0 (4)
    98: 0000000000801fe0     0 FUNC    GLOBAL DEFAULT  UND humanize_number

Symbol table '.symtab' contains 256 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00000000008001c8     0 SECTION LOCAL  DEFAULT    1 
     2: 00000000008001e0     0 SECTION LOCAL  DEFAULT    2 
     3: 0000000000800210     0 SECTION LOCAL  DEFAULT    3 
     4: 0000000000800528     0 SECTION LOCAL  DEFAULT    4 
     5: 0000000000800e70     0 SECTION LOCAL  DEFAULT    5 
     6: 000000000080127c     0 SECTION LOCAL  DEFAULT    6 
     7: 0000000000801348     0 SECTION LOCAL  DEFAULT    7 
     8: 0000000000801398     0 SECTION LOCAL  DEFAULT    8 
     9: 00000000008014b8     0 SECTION LOCAL  DEFAULT    9 
    10: 0000000000801b50     0 SECTION LOCAL  DEFAULT   10 
    11: 0000000000801b70     0 SECTION LOCAL  DEFAULT   11 
    12: 0000000000801ff0     0 SECTION LOCAL  DEFAULT   12 
    13: 00000000008059d0     0 SECTION LOCAL  DEFAULT   13 
    14: 00000000008059e8     0 SECTION LOCAL  DEFAULT   14 
    15: 0000000000807218     0 SECTION LOCAL  DEFAULT   15 
    16: 0000000000807220     0 SECTION LOCAL  DEFAULT   16 
    17: 0000000000807228     0 SECTION LOCAL  DEFAULT   17 
    18: 0000000000807238     0 SECTION LOCAL  DEFAULT   18 
    19: 0000000000807248     0 SECTION LOCAL  DEFAULT   19 
    20: 0000000000807250     0 SECTION LOCAL  DEFAULT   20 
    21: 0000000000807450     0 SECTION LOCAL  DEFAULT   21 
    22: 0000000000807460     0 SECTION LOCAL  DEFAULT   22 
    23: 00000000008076a8     0 SECTION LOCAL  DEFAULT   23 
    24: 00000000008076d8     0 SECTION LOCAL  DEFAULT   24 
    25: 0000000000807738     0 SECTION LOCAL  DEFAULT   25 
    26: 0000000000000000     0 SECTION LOCAL  DEFAULT   26 
    27: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crt1.c
    28: 000000000080346c   108 FUNC    LOCAL  DEFAULT   12 finalizer
    29: 00000000008001e0    24 OBJECT  LOCAL  DEFAULT    2 crt_noinit_tag
    30: 00000000008001f8    24 OBJECT  LOCAL  DEFAULT    2 abitag
    31: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS ls.c
    32: 00000000008038e8   112 FUNC    LOCAL  DEFAULT   12 mastercmp
    33: 000000000080770c     4 OBJECT  LOCAL  DEFAULT   24 f_listdir
    34: 0000000000807718     8 OBJECT  LOCAL  DEFAULT   24 sortfcn
    35: 0000000000801ff0  2232 FUNC    LOCAL  DEFAULT   12 display
    36: 00000000008076dc     4 OBJECT  LOCAL  DEFAULT   24 rval
    37: 0000000000807708     4 OBJECT  LOCAL  DEFAULT   24 f_listdot
    38: 0000000000807720     8 OBJECT  LOCAL  DEFAULT   24 printfcn
    39: 00000000008076d8     4 OBJECT  LOCAL  DEFAULT   24 output
    40: 00000000008028a8   656 FUNC    LOCAL  DEFAULT   12 traverse
    41: 00000000008076fc     4 OBJECT  LOCAL  DEFAULT   24 f_nosort
    42: 00000000008076f8     4 OBJECT  LOCAL  DEFAULT   24 f_recursive
    43: 00000000008076f0     4 OBJECT  LOCAL  DEFAULT   24 f_singlecol
    44: 00000000008076ec     4 OBJECT  LOCAL  DEFAULT   24 f_sizesort
    45: 00000000008076e4     4 OBJECT  LOCAL  DEFAULT   24 f_timesort
    46: 00000000008076e8     4 OBJECT  LOCAL  DEFAULT   24 f_stream
    47: 00000000008076e0     4 OBJECT  LOCAL  DEFAULT   24 f_whiteout
    48: 0000000000807700     4 OBJECT  LOCAL  DEFAULT   24 f_nofollow
    49: 0000000000807704     4 OBJECT  LOCAL  DEFAULT   24 f_noautodot
    50: 00000000008076f4     4 OBJECT  LOCAL  DEFAULT   24 f_reversesort
    51: 0000000000807710     4 OBJECT  LOCAL  DEFAULT   24 f_kblocks
    52: 0000000000807450    16 OBJECT  LOCAL  DEFAULT   21 dotav.4528
    53: 00000000008076b8     2 OBJECT  LOCAL  DEFAULT   23 dot.4527
    54: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    55: 0000000000807228     0 OBJECT  LOCAL  DEFAULT   17 __CTOR_LIST__
    56: 0000000000807238     0 OBJECT  LOCAL  DEFAULT   18 __DTOR_LIST__
    57: 0000000000807248     0 OBJECT  LOCAL  DEFAULT   19 __JCR_LIST__
    58: 0000000000803634     0 FUNC    LOCAL  DEFAULT   12 __do_global_dtors_aux
    59: 0000000000808888     1 OBJECT  LOCAL  DEFAULT   25 completed.4464
    60: 0000000000807220     0 OBJECT  LOCAL  DEFAULT   16 __do_global_dtors_aux_fin
    61: 0000000000803660     0 FUNC    LOCAL  DEFAULT   12 frame_dummy
    62: 0000000000807218     0 OBJECT  LOCAL  DEFAULT   15 __frame_dummy_init_array_
    63: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS cmp.c
    64: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS print.c
    65: 0000000000803958    40 FUNC    LOCAL  DEFAULT   12 putch
    66: 0000000000803980   128 FUNC    LOCAL  DEFAULT   12 endcolor
    67: 0000000000803c44    80 FUNC    LOCAL  DEFAULT   12 writech
    68: 0000000000803a00   244 FUNC    LOCAL  DEFAULT   12 printcolor
    69: 0000000000803af8   332 FUNC    LOCAL  DEFAULT   12 colortype
    70: 0000000000803c94   508 FUNC    LOCAL  DEFAULT   12 aclmode
    71: 00000000008076d0     4 OBJECT  LOCAL  DEFAULT   23 previous_dev.5183
    72: 00000000008076cc     4 OBJECT  LOCAL  DEFAULT   23 supports_acls.5184
    73: 00000000008076c8     4 OBJECT  LOCAL  DEFAULT   23 type.5185
    74: 0000000000803e90   440 FUNC    LOCAL  DEFAULT   12 printtime
    75: 00000000008076c4     4 OBJECT  LOCAL  DEFAULT   23 d_first.5111
    76: 0000000000807730     8 OBJECT  LOCAL  DEFAULT   24 now.5109
    77: 0000000000804048   252 FUNC    LOCAL  DEFAULT   12 printtype
    78: 0000000000804148   272 FUNC    LOCAL  DEFAULT   12 printsize.constprop.3
    79: 000000000080431c   296 FUNC    LOCAL  DEFAULT   12 printaname.isra.2
    80: 00000000008044e4   340 FUNC    LOCAL  DEFAULT   12 printlink
    81: 00000000008076c0     4 OBJECT  LOCAL  DEFAULT   23 lastentries.5065
    82: 0000000000807728     8 OBJECT  LOCAL  DEFAULT   24 array.5064
    83: 0000000000808890   132 OBJECT  LOCAL  DEFAULT   25 colors
    84: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS util.c
    85: 00000000008061b0    19 OBJECT  LOCAL  DEFAULT   14 esc.4344
    86: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    87: 0000000000807230     0 OBJECT  LOCAL  DEFAULT   17 __CTOR_END__
    88: 0000000000807240     0 OBJECT  LOCAL  DEFAULT   18 __DTOR_END__
    89: 0000000000807248     0 OBJECT  LOCAL  DEFAULT   19 __JCR_END__
    90: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
    91: 0000000000807228     0 NOTYPE  LOCAL  DEFAULT   16 __fini_array_end
    92: 0000000000807218     0 NOTYPE  LOCAL  DEFAULT   15 __preinit_array_start
    93: 0000000000801b70     0 OBJECT  LOCAL  DEFAULT   11 _PROCEDURE_LINKAGE_TABLE_
    94: 0000000000807218     0 NOTYPE  LOCAL  DEFAULT   15 __preinit_array_end
    95: 0000000000807220     0 NOTYPE  LOCAL  DEFAULT   15 __init_array_end
    96: 0000000000807220     0 NOTYPE  LOCAL  DEFAULT   16 __fini_array_start
    97: 0000000000807250     0 OBJECT  LOCAL  DEFAULT   20 _DYNAMIC
    98: 0000000000807218     0 NOTYPE  LOCAL  DEFAULT   15 __init_array_start
    99: 00000000008076a0     0 OBJECT  LOCAL  DEFAULT   22 _GLOBAL_OFFSET_TABLE_
   100: 0000000000801b90     0 FUNC    GLOBAL DEFAULT  UND fts_open@@FBSD_1.1
   101: 0000000000808920     8 OBJECT  GLOBAL DEFAULT   25 ansi_fgcol
   102: 0000000000801ba0     0 FUNC    GLOBAL DEFAULT  UND localtime@@FBSD_1.0
   103: 0000000000801bb0     0 FUNC    GLOBAL DEFAULT  UND fts_set@@FBSD_1.1
   104: 0000000000808928     4 OBJECT  GLOBAL DEFAULT   25 f_size
   105: 0000000000801bc0     0 FUNC    GLOBAL DEFAULT  UND getenv@@FBSD_1.0
   106: 0000000000801bd0     0 FUNC    GLOBAL DEFAULT  UND sscanf@@FBSD_1.0
   107: 0000000000801be0     0 FUNC    GLOBAL DEFAULT  UND atexit@@FBSD_1.0
   108: 0000000000807738     4 OBJECT  GLOBAL DEFAULT   25 optind@@FBSD_1.0
   109: 0000000000807740  4224 OBJECT  GLOBAL DEFAULT   25 _DefaultRuneLocale@@FBSD_
   110: 000000000080387c    48 FUNC    GLOBAL DEFAULT   12 sizecmp
   111: 0000000000801bf0     0 FUNC    GLOBAL DEFAULT  UND xo_finish
   112: 0000000000801c00     0 FUNC    GLOBAL DEFAULT  UND write@@FBSD_1.0
   113: 000000000080892c     4 OBJECT  GLOBAL DEFAULT   25 f_color
   114: 0000000000801c10     0 FUNC    GLOBAL DEFAULT  UND tputs
   115: 00000000008037fc    16 FUNC    GLOBAL DEFAULT   12 revbirthcmp
   116: 00000000008038b0    56 FUNC    GLOBAL DEFAULT   12 revsizecmp
   117: 0000000000808930     4 OBJECT  GLOBAL DEFAULT   25 f_flags
   118: 0000000000808934     4 OBJECT  GLOBAL DEFAULT   25 f_inode
   119: 0000000000801c20     0 FUNC    GLOBAL DEFAULT  UND xo_error
   120: 00000000008087c0     8 OBJECT  GLOBAL DEFAULT   25 _CurrentRuneLocale@@FBSD_
   121: 0000000000801c30     0 FUNC    GLOBAL DEFAULT  UND signal@@FBSD_1.0
   122: 0000000000801c40     0 FUNC    GLOBAL DEFAULT  UND setlocale@@FBSD_1.0
   123: 0000000000808938     8 OBJECT  GLOBAL DEFAULT   25 enter_bold
   124: 00000000008087c8    64 OBJECT  GLOBAL DEFAULT   25 __stack_chk_guard@@FBSD_1
   125: 0000000000805098   532 FUNC    GLOBAL DEFAULT   12 parsecolors
   126: 000000000080371c    16 FUNC    GLOBAL DEFAULT   12 revmodcmp
   127: 0000000000808940     4 OBJECT  GLOBAL DEFAULT   25 f_octal
   128: 0000000000801c50     0 FUNC    GLOBAL DEFAULT  UND strtonum@@FBSD_1.0
   129: 00000000008076d4     0 NOTYPE  GLOBAL DEFAULT   23 _edata
   130: 0000000000801c60     0 FUNC    GLOBAL DEFAULT  UND __error@@FBSD_1.0
   131: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND sp
   132: 0000000000808808     4 OBJECT  GLOBAL DEFAULT   25 __mb_sb_limit@@FBSD_1.0
   133: 0000000000801c70     0 FUNC    GLOBAL DEFAULT  UND tgoto
   134: 0000000000801c80     0 FUNC    GLOBAL DEFAULT  UND strlen@@FBSD_1.0
   135: 0000000000801c90     0 FUNC    GLOBAL DEFAULT  UND setenv@@FBSD_1.0
   136: 000000000080880c    20 NOTYPE  GLOBAL DEFAULT   25 __sys_kill@@FBSDprivate_1
   137: 0000000000801ca0     0 FUNC    GLOBAL DEFAULT  UND acl_is_trivial_np@@FBSD_1
   138: 0000000000801cb0     0 FUNC    GLOBAL DEFAULT  UND free@@FBSD_1.0
   139: 0000000000801cc0     0 FUNC    GLOBAL DEFAULT  UND xo_open_container
   140: 0000000000808820    20 NOTYPE  GLOBAL DEFAULT   25 __sys_getuid@@FBSDprivate
   141: 00000000008059d0     0 FUNC    GLOBAL HIDDEN    13 _fini
   142: 0000000000808948     8 OBJECT  GLOBAL DEFAULT   25 f_timeformat
   143: 0000000000801cd0     0 FUNC    GLOBAL DEFAULT  UND mbrtowc@@FBSD_1.0
   144: 00000000008052e4   172 FUNC    GLOBAL DEFAULT   12 prn_normal
   145: 0000000000801ce0     0 FUNC    GLOBAL DEFAULT  UND fts_read@@FBSD_1.1
   146: 0000000000808950     4 OBJECT  GLOBAL DEFAULT   25 f_accesstime
   147: 00000000008056fc   688 FUNC    GLOBAL DEFAULT   12 get_octal
   148: 0000000000801cf0     0 FUNC    GLOBAL DEFAULT  UND strchr@@FBSD_1.0
   149: 0000000000808954     4 OBJECT  GLOBAL DEFAULT   25 f_slash
   150: 0000000000801d00     0 FUNC    GLOBAL DEFAULT  UND group_from_gid@@FBSD_1.0
   151: 0000000000804290   140 FUNC    GLOBAL DEFAULT   12 printname
   152: 0000000000801d10     0 FUNC    GLOBAL DEFAULT  UND xo_warnx
   153: 000000000080372c    92 FUNC    GLOBAL DEFAULT   12 acccmp
   154: 0000000000808958     4 OBJECT  GLOBAL DEFAULT   25 f_type
   155: 0000000000801d20     0 FUNC    GLOBAL DEFAULT  UND user_from_uid@@FBSD_1.0
   156: 0000000000801d30     0 FUNC    GLOBAL DEFAULT  UND strcpy@@FBSD_1.0
   157: 0000000000808918     8 OBJECT  GLOBAL DEFAULT   25 environ
   158: 0000000000801d40     0 FUNC    GLOBAL DEFAULT  UND nl_langinfo@@FBSD_1.0
   159: 0000000000801d50     0 FUNC    GLOBAL DEFAULT  UND xo_emit
   160: 0000000000801d60     0 FUNC    GLOBAL DEFAULT  UND tgetent
   161: 000000000080895c     4 OBJECT  GLOBAL DEFAULT   25 f_label
   162: 0000000000801d70     0 FUNC    GLOBAL DEFAULT  UND snprintf@@FBSD_1.0
   163: 0000000000801d80     0 FUNC    GLOBAL DEFAULT  UND memset@@FBSD_1.0
   164: 00000000008036ac    16 FUNC    GLOBAL DEFAULT   12 revnamecmp
   165: 0000000000801d90     0 FUNC    GLOBAL DEFAULT  UND fts_children@@FBSD_1.1
   166: 0000000000808850     8 OBJECT  GLOBAL DEFAULT   25 optarg@@FBSD_1.0
   167: 0000000000801da0     0 FUNC    GLOBAL DEFAULT  UND getopt@@FBSD_1.0
   168: 0000000000801db0     0 FUNC    GLOBAL DEFAULT  UND realloc@@FBSD_1.0
   169: 0000000000808960     4 OBJECT  GLOBAL DEFAULT   25 f_longform
   170: 0000000000804bd4   384 FUNC    GLOBAL DEFAULT   12 printstream
   171: 000000000080379c    92 FUNC    GLOBAL DEFAULT   12 birthcmp
   172: 0000000000804258    56 FUNC    GLOBAL DEFAULT   12 getname
   173: 0000000000801dc0     0 FUNC    GLOBAL DEFAULT  UND mac_free@@FBSD_1.0
   174: 0000000000801dd0     0 FUNC    GLOBAL DEFAULT  UND xo_attr
   175: 0000000000801de0     0 FUNC    GLOBAL DEFAULT  UND mac_get_link@@FBSD_1.0
   176: 00000000008076b0     0 OBJECT  GLOBAL HIDDEN    23 __dso_handle
   177: 000000000080386c    16 FUNC    GLOBAL DEFAULT   12 revstatcmp
   178: 0000000000801df0     0 FUNC    GLOBAL DEFAULT  UND xo_set_version
   179: 0000000000808964     4 OBJECT  GLOBAL DEFAULT   25 f_sortacross
   180: 00000000008036a0    12 FUNC    GLOBAL DEFAULT   12 namecmp
   181: 0000000000801e00     0 FUNC    GLOBAL DEFAULT  UND strftime@@FBSD_1.0
   182: 0000000000801e10     0 FUNC    GLOBAL DEFAULT  UND acl_get_link_np@@FBSD_1.0
   183: 0000000000801e20     0 FUNC    GLOBAL DEFAULT  UND fflagstostr@@FBSD_1.0
   184: 0000000000801e30     0 FUNC    GLOBAL DEFAULT  UND strerror@@FBSD_1.0
   185: 0000000000808968     4 OBJECT  GLOBAL DEFAULT   25 f_octal_escape
   186: 0000000000805390   504 FUNC    GLOBAL DEFAULT   12 get_printable
   187: 0000000000801e40     0 FUNC    GLOBAL DEFAULT  UND xo_err
   188: 0000000000801e50     0 FUNC    GLOBAL DEFAULT  UND ___runetype@@FBSD_1.0
   189: 0000000000801e60     0 FUNC    GLOBAL DEFAULT  UND xo_close_list
   190: 000000000080896c     4 OBJECT  GLOBAL DEFAULT   25 f_sectime
   191: 0000000000801e70     0 FUNC    GLOBAL DEFAULT  UND strmode@@FBSD_1.0
   192: 00000000008076bc     4 OBJECT  GLOBAL DEFAULT   23 termwidth
   193: 0000000000808970     4 OBJECT  GLOBAL DEFAULT   25 f_numericonly
   194: 0000000000801e80     0 FUNC    GLOBAL DEFAULT  UND xo_set_flags
   195: 0000000000801e90     0 FUNC    GLOBAL DEFAULT  UND xo_open_list
   196: 00000000008089b8     0 NOTYPE  GLOBAL DEFAULT   25 _end
   197: 0000000000801ea0     0 FUNC    GLOBAL DEFAULT  UND xo_open_instance
   198: 000000000080343c     0 NOTYPE  GLOBAL DEFAULT   12 _start
   199: 000000000080886c     0 NOTYPE  WEAK   DEFAULT   25 ioctl@@FBSD_1.0
   200: 0000000000801eb0     0 FUNC    GLOBAL DEFAULT  UND exit@@FBSD_1.0
   201: 0000000000808974     4 OBJECT  GLOBAL DEFAULT   25 f_birthtime
   202: 0000000000801ec0     0 FUNC    GLOBAL DEFAULT  UND time@@FBSD_1.0
   203: 0000000000808978     4 OBJECT  GLOBAL DEFAULT   25 f_notabs
   204: 000000000080880c     0 NOTYPE  WEAK   DEFAULT   25 kill@@FBSD_1.0
   205: 0000000000801ed0     0 FUNC    GLOBAL DEFAULT  UND mac_get_file@@FBSD_1.0
   206: 00000000008076d4     0 NOTYPE  GLOBAL DEFAULT   24 __bss_start
   207: 0000000000808858    20 NOTYPE  GLOBAL DEFAULT   25 __sys_readlink@@FBSDpriva
   208: 0000000000802b38  2308 FUNC    GLOBAL DEFAULT   12 main
   209: 0000000000808880     0 NOTYPE  WEAK   DEFAULT   25 lpathconf@@FBSD_1.1
   210: 00000000008059ac    28 FUNC    GLOBAL DEFAULT   12 usage
   211: 00000000008034d8   344 FUNC    GLOBAL DEFAULT   12 __start
   212: 0000000000808820     0 NOTYPE  WEAK   DEFAULT   25 getuid@@FBSD_1.0
   213: 00000000008036bc    92 FUNC    GLOBAL DEFAULT   12 modcmp
   214: 000000000080897c     4 OBJECT  GLOBAL DEFAULT   25 f_thousands
   215: 0000000000801ee0     0 FUNC    GLOBAL DEFAULT  UND asprintf@@FBSD_1.0
   216: 0000000000808980     4 OBJECT  GLOBAL DEFAULT   25 f_statustime
   217: 0000000000801ef0     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@@FBSD_1.
   218: 0000000000808858     0 NOTYPE  WEAK   DEFAULT   25 readlink@@FBSD_1.0
   219: 0000000000801f00     0 FUNC    GLOBAL DEFAULT  UND getbsize@@FBSD_1.0
   220: 000000000080378c    16 FUNC    GLOBAL DEFAULT   12 revacccmp
   221: 0000000000808838    20 NOTYPE  GLOBAL DEFAULT   25 __sys_getpid@@FBSDprivate
   222: 0000000000804448   156 FUNC    GLOBAL DEFAULT   12 printscol
   223: 0000000000801f10     0 FUNC    GLOBAL DEFAULT  UND mac_prepare_file_label@@F
   224: 0000000000808984     4 OBJECT  GLOBAL DEFAULT   25 f_humanval
   225: 0000000000801f20     0 FUNC    GLOBAL DEFAULT  UND strcoll@@FBSD_1.0
   226: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
   227: 0000000000808988     8 OBJECT  GLOBAL DEFAULT   25 ansi_bgcol
   228: 0000000000801f30     0 FUNC    GLOBAL DEFAULT  UND tgetstr
   229: 0000000000801f40     0 FUNC    GLOBAL DEFAULT  UND xo_parse_args
   230: 00000000008052ac    56 FUNC    GLOBAL DEFAULT   12 colorquit
   231: 0000000000801f50     0 FUNC    GLOBAL DEFAULT  UND xo_warn
   232: 0000000000801f60     0 FUNC    GLOBAL DEFAULT  UND isatty@@FBSD_1.0
   233: 0000000000808990     8 OBJECT  GLOBAL DEFAULT   25 blocksize
   234: 0000000000808838     0 NOTYPE  WEAK   DEFAULT   25 getpid@@FBSD_1.0
   235: 0000000000808998     4 OBJECT  GLOBAL DEFAULT   25 f_samesort
   236: 000000000080380c    92 FUNC    GLOBAL DEFAULT   12 statcmp
   237: 00000000008089a0     8 OBJECT  GLOBAL DEFAULT   25 ansi_coloff
   238: 0000000000801f70     0 FUNC    GLOBAL DEFAULT  UND mac_to_text@@FBSD_1.0
   239: 0000000000801f80     0 FUNC    GLOBAL DEFAULT  UND xo_close_instance
   240: 0000000000801f90     0 FUNC    GLOBAL DEFAULT  UND xo_close_container
   241: 00000000008089a8     8 OBJECT  GLOBAL DEFAULT   25 attrs_off
   242: 0000000000801fa0     0 FUNC    GLOBAL DEFAULT  UND strdup@@FBSD_1.0
   243: 0000000000801fb0     0 FUNC    GLOBAL DEFAULT  UND acl_free@@FBSD_1.0
   244: 0000000000801fc0     0 FUNC    GLOBAL DEFAULT  UND malloc@@FBSD_1.0
   245: 00000000008076a8     8 OBJECT  GLOBAL DEFAULT   23 __progname
   246: 0000000000001668     8 TLS     GLOBAL DEFAULT   25 _ThreadRuneLocale@@FBSD_1
   247: 00000000008089b0     4 OBJECT  GLOBAL DEFAULT   25 f_nonprint
   248: 0000000000801b50     0 FUNC    GLOBAL HIDDEN    10 _init
   249: 0000000000805588   372 FUNC    GLOBAL DEFAULT   12 len_octal
   250: 0000000000801fd0     0 FUNC    GLOBAL DEFAULT  UND _init_tls@@FBSD_1.0
   251: 0000000000804d54   832 FUNC    GLOBAL DEFAULT   12 printcol
   252: 000000000080886c    20 NOTYPE  GLOBAL DEFAULT   25 __sys_ioctl@@FBSDprivate_
   253: 0000000000807ea8     0 NOTYPE  GLOBAL DEFAULT   23 _gp
   254: 0000000000801fe0     0 FUNC    GLOBAL DEFAULT  UND humanize_number
   255: 0000000000804638  1436 FUNC    GLOBAL DEFAULT   12 printlong

Histogram for bucket list length (total of 97 buckets):
 Length  Number     % of total  Coverage
      0  35         ( 36.1%)
      1  37         ( 38.1%)     37.8%
      2  16         ( 16.5%)     70.4%
      3  7          (  7.2%)     91.8%
      4  2          (  2.1%)    100.0%

Version symbols section '.gnu.version' contains 99 entries:
 Addr: 000000000080127c  Offset: 0x00127c  Link: 4 (.dynsym)
  000:   0 (*local*)       2 (FBSD_1.1)      3 (FBSD_1.0)      2 (FBSD_1.1)   
  004:   3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)   
  008:   3 (FBSD_1.0)      0 (*local*)       3 (FBSD_1.0)      0 (*local*)    
  00c:   0 (*local*)       3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)   
  010:   3 (FBSD_1.0)      3 (FBSD_1.0)      1 (*global*)      3 (FBSD_1.0)   
  014:   0 (*local*)       3 (FBSD_1.0)      0 (*local*)       3 (FBSD_1.0)   
  018:   3 (FBSD_1.0)      4 (FBSDprivate_1.0)     2 (FBSD_1.1)      3 (FBSD_1.0)   
  01c:   0 (*local*)       4 (FBSDprivate_1.0)     3 (FBSD_1.0)      2 (FBSD_1.1)   
  020:   4 (FBSDprivate_1.0)     3 (FBSD_1.0)      4 (FBSDprivate_1.0)     3 (FBSD_1.0)   
  024:   0 (*local*)       3 (FBSD_1.0)      3 (FBSD_1.0)      1 (*global*)   
  028:   3 (FBSD_1.0)      0 (*local*)       0 (*local*)       3 (FBSD_1.0)   
  02c:   3 (FBSD_1.0)      2 (FBSD_1.1)      3 (FBSD_1.0)      3 (FBSD_1.0)   
  030:   3 (FBSD_1.0)      3 (FBSD_1.0)      0 (*local*)       3 (FBSD_1.0)   
  034:   0 (*local*)       3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)   
  038:   4 (FBSDprivate_1.0)     3 (FBSD_1.0)      0 (*local*)       3 (FBSD_1.0)   
  03c:   0 (*local*)       3 (FBSD_1.0)      0 (*local*)       0 (*local*)    
  040:   1 (*global*)      0 (*local*)       3 (FBSD_1.0)      3 (FBSD_1.0)   
  044:   3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)      1 (*global*)   
  048:   4 (FBSDprivate_1.0)     2 (FBSD_1.1)      3 (FBSD_1.0)      3 (FBSD_1.0)   
  04c:   3 (FBSD_1.0)      3 (FBSD_1.0)      3 (FBSD_1.0)      4 (FBSDprivate_1.0)  
  050:   3 (FBSD_1.0)      3 (FBSD_1.0)      0 (*local*)       0 (*local*)    
  054:   0 (*local*)       0 (*local*)       3 (FBSD_1.0)      3 (FBSD_1.0)   
  058:   3 (FBSD_1.0)      0 (*local*)       0 (*local*)       3 (FBSD_1.0)   
  05c:   3 (FBSD_1.0)      3 (FBSD_1.0)      1 (*global*)      5 (FBSD_1.3)   
  060:   3 (FBSD_1.0)      4 (FBSDprivate_1.0)     0 (*local*)    

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x0000000000801348  Offset: 0x001348  Link: 5 (.dynstr)
  000000: Version: 1  File: libc.so.7  Cnt: 4
  0x0010:   Name: FBSD_1.3  Flags: none  Version: 5
  0x0020:   Name: FBSDprivate_1.0  Flags: none  Version: 4
  0x0030:   Name: FBSD_1.0  Flags: none  Version: 3
  0x0040:   Name: FBSD_1.1  Flags: none  Version: 2

Displaying notes found at file offset 0x000001e0 with length 0x00000030:
  Owner                 Data size   Description
  FreeBSD              0x00000004   NT_ARCH (architecture)
  FreeBSD              0x00000004   NT_VERSION (version)
$ 

Support for RoCC (Xcustom) by default

I recently updated rocket-chip to master, but the RV toolchain it references (b85637e) no longer supports RoCC (Xcustom) instructions (e.g., custom0) by default. It seems like there may be a temporary fix in there with d836766 (I'm building HEAD to test this now using --with-arch=RV64IMAFDXcustom).

Is there an existing way to enable Xcustom support? Should this be turned on by default? I can't quite tell what the ISA Spec intends regarding the latter question as far as custom0 and custom1 are concerned.

Newlib toolchain: Can't build hello world

I built the Newlib riscv-gnu-toolchain on Ubuntu 14.04 succesfully, but I see linker errors when I try to build the standard helloworld program.

arun@yoshi:/tmp$ riscv64-unknown-elf-gcc -o hello hello.c
/opt/riscv/lib/gcc/riscv64-unknown-elf/4.9.2/../../../../riscv64-unknown-elf/lib/crt0.o: In function `.LX3':
(.text+0x24): undefined reference to `__libc_fini_array'
/opt/riscv/lib/gcc/riscv64-unknown-elf/4.9.2/../../../../riscv64-unknown-elf/lib/crt0.o: In function `.LX3':
(.text+0x30): undefined reference to `__libc_init_array'
collect2: error: ld returned 1 exit status

The __libc_init_array and __libc_fini_array symbols are not defined in libc.a or the other libraries/object files in /opt/riscv/riscv64-unknown-elf/lib.

Problem compiling with "make linux" -- [-Werror=unused-value]

Debian GNU/Linux, unstable (most recent version of packages)

gcc -DHAVE_CONFIG_H -I. -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas -I. -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas -I../bfd -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/config -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/../include -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/.. -I/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/../bfd -DLOCALEDIR=""/home/mafm/prj/riscv/riscv-gnu-toolchain/../install-path/share/locale"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -Wno-error=deprecated-declarations -MT atof-ieee.o -MD -MP -MF .deps/atof-ieee.Tpo -c -o atof-ieee.o test -f 'config/atof-ieee.c' || echo '/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/'config/atof-ieee.c
mv -f .deps/dwarf2dbg.Tpo .deps/dwarf2dbg.Po
In file included from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/as.h:95:0,
from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/write.c:25:
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/write.c: In function ‘record_alignment’:
../bfd/bfd.h:303:83: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
^
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/write.c:366:5: note: in expansion of macro ‘bfd_set_section_alignment’
bfd_set_section_alignment (stdoutput, seg, align);
^
In file included from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/as.h:95:0,
from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/subsegs.c:25:
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/subsegs.c: In function ‘subseg_change’:
../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
^
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/subsegs.c:70:7: note: in expansion of macro ‘bfd_set_section_userdata’
bfd_set_section_userdata (stdoutput, seg, seginfo);
^
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/subsegs.c: In function ‘subseg_get’:
../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
^
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/subsegs.c:172:7: note: in expansion of macro ‘bfd_set_section_userdata’
bfd_set_section_userdata (stdoutput, secptr, seginfo);
^
mv -f .deps/remap.Tpo .deps/remap.Po
cc1: all warnings being treated as errors
Makefile:894: recipe for target 'subsegs.o' failed
make[5]: *** [subsegs.o] Error 1
make[5]: *** Waiting for unfinished jobs....
mv -f .deps/output-file.Tpo .deps/output-file.Po
mv -f .deps/sb.Tpo .deps/sb.Po
mv -f .deps/expr.Tpo .deps/expr.Po
In file included from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/as.h:95:0,
from /home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/config/obj-elf.c:24:
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/config/obj-elf.c: In function ‘obj_elf_init_stab_section’:
../bfd/bfd.h:303:83: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
^
/home/mafm/prj/riscv/riscv-gnu-toolchain/src/binutils/gas/config/obj-elf.c:1940:3: note: in expansion of macro ‘bfd_set_section_alignment’
bfd_set_section_alignment (stdoutput, seg, 2);
^
mv -f .deps/messages.Tpo .deps/messages.Po
mv -f .deps/listing.Tpo .deps/listing.Po
mv -f .deps/stabs.Tpo .deps/stabs.Po
mv -f .deps/macro.Tpo .deps/macro.Po
mv -f .deps/atof-ieee.Tpo .deps/atof-ieee.Po
cc1: all warnings being treated as errors
Makefile:894: recipe for target 'write.o' failed
make[5]: *** [write.o] Error 1
cc1: all warnings being treated as errors
Makefile:1951: recipe for target 'obj-elf.o' failed
make[5]: *** [obj-elf.o] Error 1
mv -f .deps/tc-riscv.Tpo .deps/tc-riscv.Po
mv -f .deps/read.Tpo .deps/read.Po
mv -f .deps/symbols.Tpo .deps/symbols.Po
make[5]: Leaving directory '/home/mafm/prj/riscv/riscv-gnu-toolchain/build-binutils-linux/gas'
Makefile:2182: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/home/mafm/prj/riscv/riscv-gnu-toolchain/build-binutils-linux/gas'
Makefile:684: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/mafm/prj/riscv/riscv-gnu-toolchain/build-binutils-linux/gas'
Makefile:4710: recipe for target 'all-gas' failed
make[2]: *** [all-gas] Error 2
make[2]: Leaving directory '/home/mafm/prj/riscv/riscv-gnu-toolchain/build-binutils-linux'
Makefile:830: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/mafm/prj/riscv/riscv-gnu-toolchain/build-binutils-linux'
Makefile:69: recipe for target 'build-binutils-linux' failed
make: *** [build-binutils-linux] Error 2

Wrong syntax in usr/include/bits/mathcalls.h ?

Hi,

Trying to compile libvorbis fails with the following errors. Given that it's a file shipped by you I think that it's a problem with the toolchain port, so reporting just in case:

In file included from /usr/include/math.h:69:0,
                 from mdct.c:43:
/usr/local/sysroot/usr/include/bits/mathcalls.h:63:21: error: expected ')' before ',' token
 __MATHCALL_VEC (cos,, (_Mdouble_ __x));
                     ^
/usr/local/sysroot/usr/include/bits/mathcalls.h:65:21: error: expected ')' before ',' token
 __MATHCALL_VEC (sin,, (_Mdouble_ __x));
                     ^
/usr/local/sysroot/usr/include/bits/mathcalls.h:100:21: error: expected ')' before ',' token
 __MATHCALL_VEC (exp,, (_Mdouble_ __x));
                     ^
/usr/local/sysroot/usr/include/bits/mathcalls.h:109:21: error: expected ')' before ',' token
 __MATHCALL_VEC (log,, (_Mdouble_ __x));
                     ^
/usr/local/sysroot/usr/include/bits/mathcalls.h:153:21: error: expected ')' before ',' token
 __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
                     ^

Compiled binaries not working in riscv-qemu

I am not sure if this is a problem with this project, or riscv-qemu, or something else that I am doing wrong.

I have the following test program, compiled with the commands below:

#include <stdio.h>

int main() {
        printf("Size of %s: %d\n", "unsigned long long", sizeof(unsigned long long));

        printf("Max of %s: %llu\n", "unsigned long long", 18446744073709551615ULL);
}
$ PATH=~/prj/riscv/install-path/bin/:$PATH riscv64-unknown-linux-gnu-gcc /tmp/test.c -static -o /tmp/test-static
$ PATH=~/prj/riscv/install-path/bin/:$PATH riscv64-unknown-linux-gnu-gcc /tmp/test.c -o /tmp/test
$ file /tmp/test /tmp/test-static 
/tmp/test:        ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped
/tmp/test-static: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, for GNU/Linux 2.4.1, not stripped

When executed in qemu, using kernel from the link in "getting started" and the root image with busybox, neither of the binaries work:

/ # ./test
Inconsistency detected by ld.so: dynamic-link.h: 185: elf_get_dynamic_info: Assertion `info[20]->d_un.d_val == 17' failed!
/ # ./test-static
Segmentation fault

(I cross-compiled other complex projects, like 'make', and apparently the compilation went fine. But when I try to execute them inside qemu, the result is the same. At this point is when I went back a step and tried to create the minimal test programs above, which also fail.)

The binaries from the qemu image provided, all of them coming from busybox, work fine:

/ # date
Thu Jan  1 00:02:15 UTC 1970
/ # uname -a
Linux ucbvax 3.14.13-g91d31d7 #8 Tue Jul 22 13:42:39 PDT 2014 riscv GNU/Linux
/ # stat /test /test-static
  File: /test
  Size: 16973           Blocks: 40         IO Block: 4096   regular file
Device: fe00h/65024d    Inode: 17          Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/ UNKNOWN)   Gid: ( 1000/ UNKNOWN)
Access: 1970-01-01 00:00:04.000000000
Modify: 2014-11-01 19:18:06.000000000
Change: 2014-11-01 19:21:18.000000000

  File: /test-static
  Size: 3717976         Blocks: 7272       IO Block: 4096   regular file
Device: fe00h/65024d    Inode: 16          Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/ UNKNOWN)   Gid: ( 1000/ UNKNOWN)
Access: 1970-01-01 00:00:08.000000000
Modify: 2014-11-01 19:18:02.000000000
Change: 2014-11-01 19:21:18.000000000

Am I doing something wrong? Is this something expected at the moment because the ports of the tools are still WIP, so better if I stop playing around with this until the tools are more stable? (I am not sure if these bug reports are useful, or if at this point I am mostly wasting your time).

Linker does not produce raw binary files, even though it says it can.

Please see my gist here. https://gist.github.com/sam-falvo/a3aba3db13b382224cfc

After compiling the hw.c program and creating the linker script, nothing I do seems to convince the GNU ld command to produce a real, honest-to-goodness binary file. It always produces an ELF, no matter what.

I'm at a loss on how to proceed from here. This is either a very subtle user-error on my part, or it's a bug in ld.

Here's the help output for ld:

... lots of text elided ...
/opt/riscv/bin/riscv64-unknown-elf-ld: supported targets: elf64-littleriscv elf32-littleriscv elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
/opt/riscv/bin/riscv64-unknown-elf-ld: supported emulations: elf64lriscv elf32lriscv
/opt/riscv/bin/riscv64-unknown-elf-ld: emulation specific options:
... lots more text elided ...

Any ideas?

Error: unrecognizable insn

While trying to work around the other error I was getting, I encountered the following error.

/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/libgcc/libgcc2.c: In function '__absvdi2':
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/libgcc/libgcc2.c:232:1: error: unrecognizable insn:
 }
 ^
(call_insn 15 14 16 5 (parallel [
            (call (mem:SI (symbol_ref:DI ("abort") [flags 0x41] <function_decl 0x7f4cc8b40d00 abort>) [0 __builtin_abort S4 A32])
                (const_int 0 [0]))
            (clobber (reg:SI 1 ra))
        ]) /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/libgcc/libgcc2.c:228 -1
     (expr_list:REG_NORETURN (const_int 0 [0])
        (expr_list:REG_EH_REGION (const_int 0 [0])
            (nil)))
    (nil))
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/libgcc/libgcc2.c:232:1: internal compiler error: in extract_insn, at recog.c:2202
0x7ae2c3 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/rtl-error.c:109
0x7ae2f9 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/rtl-error.c:117
0x785f4a extract_insn(rtx_def*)
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/recog.c:2202
0x660ff0 instantiate_virtual_regs_in_insn
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/function.c:1607
0x660ff0 instantiate_virtual_regs
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/function.c:1925
0x660ff0 execute
        /home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/newlib-gcc/gcc/function.c:1975
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Makefile:463: recipe for target '_absvsi2.o' failed
make[5]: *** [_absvsi2.o] Error 1
make[5]: Leaving directory '/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/build-gcc-newlib/riscv64-unknown-elf/soft-float/libgcc'
Makefile:1136: recipe for target 'multi-do' failed
make[4]: *** [multi-do] Error 1
make[4]: Leaving directory '/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/build-gcc-newlib/riscv64-unknown-elf/libgcc'
Makefile:114: recipe for target 'all-multi' failed
make[3]: *** [all-multi] Error 2
make[3]: Leaving directory '/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/build-gcc-newlib/riscv64-unknown-elf/libgcc'
Makefile:10861: recipe for target 'all-target-libgcc' failed
make[2]: *** [all-target-libgcc] Error 2
make[2]: Leaving directory '/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/build-gcc-newlib'
Makefile:855: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/build-gcc-newlib'
Makefile:150: recipe for target 'stamps/build-gcc-newlib' failed
make: *** [stamps/build-gcc-newlib] Error 2

32-Bit Linux compilation broken

One of the latest patches break the compilation of the Linux kernel for the 32-Bit toolchain.

The problems occurs somewhere after patch 3ae3d5b

The output of the Linux kernel compilation is:

CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
LINK vmlinux
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
init/built-in.o: In function run_init_process': main.c:(.text+0x0): undefined reference to__riscv_save_2'
main.c:(.text+0x24): undefined reference to __riscv_restore_2' main.c:(.text+0x2c): undefined reference to__riscv_save_1'
init/built-in.o: In function try_to_run_init_process': main.c:(.text+0x70): undefined reference to__riscv_restore_1'
init/built-in.o: In function match_dev_by_uuid': do_mounts.c:(.text+0x84): undefined reference to__riscv_save_0'
do_mounts.c:(.text+0x9c): undefined reference to __riscv_restore_0' init/built-in.o: In functionrootfs_mount':
do_mounts.c:(.text+0xec): undefined reference to __riscv_save_2' init/built-in.o: In function.L97':
do_mounts.c:(.text+0x474): undefined reference to __riscv_restore_2' do_mounts.c:(.text+0x488): undefined reference to__riscv_save_12'
init/built-in.o: In function .L35': calibrate.c:(.text+0x860): undefined reference to__riscv_restore_12'
init/built-in.o: In function .L9': main.c:(.init.text+0x8c): undefined reference to__riscv_save_7'
init/built-in.o: In function .L14': main.c:(.init.text+0x128): undefined reference to__riscv_restore_7'

RVC: c.bnez not encoded correctly

When compiling code for RV32C, c.bnez instructions are translated incorrectly from RV32. It looks like a simple encoding issue, where a few bits got lost or were shifted. Both the immediate and the involved register is wrong.

Example objdump output (RV32I):

1c000052: 02051463            bnez  a0,1c00007a <synch_start>
1c000056 <memory_init>:
[...]
1c00007a <synch_start>:

Corresponding RV32C code:

1c000046: 601a                  bnez  s0,1c00004c <memory_init+0x4>
1c000048 <memory_init>:
[...]
1c00006a <synch_start>:

The objdump output corresponds with the RVC standard, so the problem must be in the RVI -> RVC translation step.

The toolchain's configure --with-arch flag is not symmetric with gcc's --with-arch

Hey guys,

Currently, to build an RV32I toolchain we do:

../configure --with-xlen=32 --with-arch=I --prefix=$RISCV 

That's not symmetric with the other --with-arch flags, which expect "--with-arch=RV32I".

Ideally, the toolchain configure would be performed as:

    ../configure --with-arch=RV32I --prefix=$RISCV 

(Conceptually) the "32" would be passed to "--with-xlen", and the entire "RV32I" string would be passed to the other "--with-arch" flags.

Configure is not my forte, so it's not obvious to me how to set the @xlen@ variable based on the @arch@ variable, and whether you can perform that action if the --with-xlen flag was used or not.

Although perhaps we no longer need the --with-xlen flag, in which case XLEN is just ${ARCH:2:2}?

Broken --with-xlen=32 --with-arch=I

The binaries and libraries built with --with-xlen=32 --with-arch=I (git 77f7450, current master) do not seem to match the requested configuration, or each other:

Build script:

git clone https://github.com/riscv/riscv-gnu-toolchain riscv-gnu-toolchain-rv32i
cd riscv-gnu-toolchain-rv32i/
mkdir build; cd build
../configure --with-xlen=32 --with-arch=I --prefix=/opt/riscv32i
make -j$(nproc)

Tests:

$ cat > test.c << EOT
int main() {
  return 0;
}
EOT

$ riscv32-unknown-elf-gcc -c test.c
$ riscv32-unknown-elf-objdump -a test.o
test.o: file format elf64-littleriscv

$ riscv32-unknown-elf-gcc -m32 -c test.c
$ riscv32-unknown-elf-objdump -a test.o
test.o: file format elf32-littleriscv

$ riscv32-unknown-elf-objdump -a /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtend.o
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtend.o: file format elf64-littleriscv

So far it just looks like the configuration did not "stick". But look it this:

$ riscv32-unknown-elf-gcc test.c
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
compilation terminated.
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/crt0.o: ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/crt0.o
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtbegin.o: ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtbegin.o
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /tmp/ccAktjEO.o: ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /tmp/ccAktjEO.o
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtend.o: ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/crtend.o
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-atexit.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-atexit.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-exit.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-exit.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-fini.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-fini.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-impure.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-impure.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-init.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-init.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-__atexit.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-__atexit.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-__call_atexit.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-__call_atexit.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libgloss.a(syscalls.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libgloss.a(syscalls.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/libgcc.a(mul.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/libgcc.a(mul.o)
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-errno.o): ABI is incompatible with that of the selected emulation
/opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv32i/lib/gcc/riscv32-unknown-elf/5.2.0/../../../../riscv32-unknown-elf/lib/libc.a(lib_a-errno.o)

"-msoft-float" flag generates broken binaries when using glibc

I attempted to use riscv64-unknown-linux-gnu-gcc -msoft-float to compile SPECINT (which has a shocking amount of floating point).

The code compiles, but the resulting binaries compute garbage when it comes to floating point. I've been told that glibc does not "support" -msoft-float, so that's suddenly not a surprise.

Question

Is there a way for this combination to noisily complain to prevent users from thinking "my code compiled, thus it should work"? Or should I just wait on a multi-lib implementation of glibc instead?

Assertion failure in md_apply_fix

The following source file (bug.S):

         sw     x9, 4, x1

And command: /opt/riscv/bin/riscv64-unknown-elf-gcc -c bug.S

Leads to this crash:

/tmp/ccbUoWbX.s: Assembler messages:
/tmp/ccbUoWbX.s: Internal error!
Assertion failure in md_apply_fix at /data/home/tnewsome/riscv-gnu-toolchain/src/binutils/gas/config/tc-riscv.c line 1889.
Please report this bug.

Compile file including math.h with -O and -pedantic flags causes error

-------------------------command--------------------------------------------------------
riscv64-unknown-linux-gnu-gcc -O -pedantic test.cpp

-------------------------test.cpp----------------------------------------------------------------

include <math.h>

int main() {
return 0;
}

---------------------------Errors--------------------------------------------------------
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int signbit(double)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:51:59: error: declaration of 'int __signbit(double)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbit (double __x)
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/features.h:365:0,
from /opt/riscv/toolchain/sysroot/usr/include/math.h:26,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbit(double) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbitf(float)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:58:59: error: declaration of 'int __signbitf(float)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbitf (float __x)
^
In file included from test.cpp:1:0:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbitf(float) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
main@main-pc:$ riscv64-unknown-linux-gnu-gcc -O -pedantic math.h
riscv64-unknown-linux-gnu-gcc: error: math.h: No such file or directory
riscv64-unknown-linux-gnu-gcc: fatal error: no input files
compilation terminated.
main@main-pc:
$ riscv64-unknown-linux-gnu-gcc -O -pedantic test.cpp
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbit(double)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:51:59: error: declaration of 'int __signbit(double)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbit (double __x)
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/features.h:365:0,
from /opt/riscv/toolchain/sysroot/usr/include/math.h:26,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbit(double) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbitf(float)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:58:59: error: declaration of 'int __signbitf(float)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbitf (float __x)
^
In file included from test.cpp:1:0:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbitf(float) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
main@main-pc:~$ riscv64-unknown-linux-gnu-gcc -O -pedantic test.cpp > test.error
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbit(double)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:51:59: error: declaration of 'int __signbit(double)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbit (double __x)
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/features.h:365:0,
from /opt/riscv/toolchain/sysroot/usr/include/math.h:26,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbit(double) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbitf(float)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:58:59: error: declaration of 'int __signbitf(float)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbitf (float __x)
^
In file included from test.cpp:1:0:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbitf(float) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
main@main-pc:~$ riscv64-unknown-linux-gnu-gcc -O -pedantic test.cpp > test.error
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbit(double)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:51:59: error: declaration of 'int __signbit(double)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbit (double __x)
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/features.h:365:0,
from /opt/riscv/toolchain/sysroot/usr/include/math.h:26,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbit(double) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbitf(float)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:58:59: error: declaration of 'int __signbitf(float)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbitf (float __x)
^
In file included from test.cpp:1:0:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbitf(float) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
main@main-pc:$ cat test.error
main@main-pc:
$ riscv64-unknown-linux-gnu-gcc -O -pedantic test.cpp 2> test.error
main@main-pc:~$ cat test.error
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbit(double)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:51:59: error: declaration of 'int __signbit(double)' has a different exception specifier
__MATH_INLINE int __attribute_used
signbit (double __x)
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/features.h:365:0,
from /opt/riscv/toolchain/sysroot/usr/include/math.h:26,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbit(double) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^
In file included from /opt/riscv/toolchain/sysroot/usr/include/math.h:427:0,
from test.cpp:1:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h: In function 'int __signbitf(float)':
/opt/riscv/toolchain/sysroot/usr/include/bits/mathinline.h:58:59: error: declaration of 'int __signbitf(float)' has a different exception specifier
__MATH_INLINE int __attribute_used
__signbitf (float __x)
^
In file included from test.cpp:1:0:
/opt/riscv/toolchain/sysroot/usr/include/bits/mathcalls.h:351:1: error: from previous declaration 'int __signbitf(float) throw ()'
__MATHDECL_1 (int, __signbit,, (Mdouble __value))
^

No libgcc.a for -m32 -march=RV32I

I used to be able to create RV32I binaries that use symbols such as __mulsi3 from libgcc like this:

riscv64-unknown-elf-gcc -c -m32 -march=RV32I -ffreestanding -nostdlib test.c
riscv64-unknown-elf-gcc -m32 -march=RV32I -ffreestanding -nostdlib -o test.elf test.o -lgcc

Here is an example test.c that wants to use __mulsi3:

#include <stdint.h>

void _start(uint32_t a, uint32_t b)
{
    uint64_t au = a, bu = b;
    int64_t as = (int32_t)a, bs = (int32_t)b;
    uint32_t s_mul, s_mulh, s_mulhsu, s_mulhu;

    s_mul = a * b;
    s_mulh = (as * bs) >> 32;
    s_mulhsu = (as * bu) >> 32;
    s_mulhu = (au * bu) >> 32;

    if (s_mul == s_mulh || s_mulhsu == s_mulhu)
        __asm__ volatile ("sbreak");
}

With git head of riscv-gnu-toolchain (1ad4bfc) I can't do that anymore and get the following error:

$ riscv64-unknown-elf-gcc -m32 -march=RV32I -ffreestanding -nostdlib -o test.elf test.o -lgcc
/opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/libgcc.a(mul.o): ABI is incompatible with that of the selected emulation
/opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/libgcc.a(mul.o)
test.o: In function `_start':
test.c:(.text+0x70): undefined reference to `__mulsi3'
collect2: error: ld returned 1 exit status

There used to be a /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/32/libgcc.a, but it's not there anymore. Do I need to build multilib support for this, even when I don't use any libraries but just want full C language support for integer ops? This seems a little bit odd to me..

relocation truncated to fit: R_RISCV_JAL when compiling linux

Hi,

when I compile my kernel (32-Bit toolchain) I get the following error.

  LINK    vmlinux
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  KSYM    .tmp_kallsyms1.o
net/built-in.o: In function `netlink_proto_init':
af_netlink.c:(.init.text+0x924): relocation truncated to fit: R_RISCV_JAL against symbol `rhashtable_init' defined in .text section in lib/built-in.o
Makefile:932: recipe for target 'vmlinux' failed

Looks like I hit the 20 bit limit of the instruction. It works when I remove certain features from the kernel.

I get an similar error "unresolvable R_RISCV_PCREL_HI20 relocation against symbol" when I try to compile DirectFB.

libgcc build error

I ran the following command:
git clone https://github.com/ucb-bar/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain/
./configure --prefix=/opt/riscv-gcc
make

But the build stop with the following message:

make[3]: Leaving directory /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/gcc' Checking multilib configuration for libgcc... mkdir -p -- riscv-elf/libgcc Configuring in riscv-elf/libgcc configure: creating cache ./config.cache checking build system type... x86_64-unknown-linux-gnu checking host system type... riscv-ucb-elf checking for --enable-version-specific-runtime-libs... no checking for a BSD-compatible install... /usr/bin/install -c checking for gawk... gawk checking for riscv-elf-ar... riscv-elf-ar checking for riscv-elf-lipo... riscv-elf-lipo checking for riscv-elf-nm... /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/nm checking for riscv-elf-ranlib... riscv-elf-ranlib checking for riscv-elf-strip... riscv-elf-strip checking whether ln -s works... yes checking for riscv-elf-gcc... /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/xgcc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/ -nostdinc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/include -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/libgloss/riscv -B/opt/riscv-gcc/riscv-elf/bin/ -B/opt/riscv-gcc/riscv-elf/lib/ -isystem /opt/riscv-gcc/riscv-elf/include -isystem /opt/riscv-gcc/riscv-elf/sys-include checking for suffix of object files... configure: error: in/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.

The error(s) in the config.log :

configure:3373: $? = 0
configure:3362: /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/xgcc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/ -nostdinc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/include -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/libgloss/riscv -B/opt/riscv-gcc/riscv-elf/bin/ -B/opt/riscv-gcc/riscv-elf/lib/ -isystem /opt/riscv-gcc/riscv-elf/include -isystem /opt/riscv-gcc/riscv-elf/sys-include -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3373: $? = 1
configure:3362: /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/xgcc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/ -nostdinc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/include -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/libgloss/riscv -B/opt/riscv-gcc/riscv-elf/bin/ -B/opt/riscv-gcc/riscv-elf/lib/ -isystem /opt/riscv-gcc/riscv-elf/include -isystem /opt/riscv-gcc/riscv-elf/sys-include -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3373: $? = 1
configure:3389: /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/xgcc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/ -nostdinc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/include -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/libgloss/riscv -B/opt/riscv-gcc/riscv-elf/bin/ -B/opt/riscv-gcc/riscv-elf/lib/ -isystem /opt/riscv-gcc/riscv-elf/include -isystem /opt/riscv-gcc/riscv-elf/sys-include -o conftest -g -O2 conftest.c >&5
/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/as: line 106: exec: -m: invalid option
exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
configure:3392: $? = 1
configure:3580: checking for suffix of object files
configure:3602: /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/xgcc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/ -nostdinc -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/ -isystem /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/newlib/targ-include -isystem /home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/include -B/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/riscv -L/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgloss/libnosys -L/home/ronan/perso/github/riscv-gnu-toolchain/src/newlib-gcc/libgloss/riscv -B/opt/riscv-gcc/riscv-elf/bin/ -B/opt/riscv-gcc/riscv-elf/lib/ -isystem /opt/riscv-gcc/riscv-elf/include -isystem /opt/riscv-gcc/riscv-elf/sys-include -c -g -O2 conftest.c >&5
/home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/./gcc/as: line 106: exec: -m: invalid option
exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
configure:3606: $? = 1
configure: failed program was:
| /* confdefs.h /
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /
end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3620: error: in /home/ronan/perso/github/riscv-gnu-toolchain/build-gcc-newlib/riscv-elf/libgcc': configure:3623: error: cannot compute suffix of object files: cannot compile Seeconfig.log' for more details.

adding new opode extensions

at the bottom of riscv-opc.c there is comment

/* Removed const from the following to allow for dynamic extensions to the
   built-in instruction set.  */
struct riscv_opcode *riscv_opcodes =
  (struct riscv_opcode *) riscv_builtin_opcodes;
int bfd_riscv_num_opcodes = RISCV_NUM_OPCODES;

This seems to indicate that there is a [planned] way to easily add instructions. Is there currently a clean way of doing this?
I've currently hacked the riscv_buildin_opcodes data structure to add my extensions, but I would love to know if there is a better way of doing this.

Problem compiling with "make linux" -- "__BYTE_ORDER" is not defined

Compiling with the following command (see issue #3 as for why the CPPFLAGS is necessary):

  CPPFLAGS="-Wno-error=unused-value" make linux

leads to the following error (and many more lines like these):

In file included from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:23:0,
                 from <stdin>:1:
../sysdeps/riscv/nptl/tls.h:44:16: error: invalid register name for ‘__thread_self’
 register void* __thread_self asm("tp");
                ^
In file included from ../include/endian.h:1:0,
                 from ../posix/sys/types.h:216,
                 from ../include/sys/types.h:1,
                 from ../nptl/descr.h:26,
                 from ../sysdeps/riscv/nptl/tls.h:55,
                 from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:23,
                 from <stdin>:1:
../string/endian.h:51:5: warning: "__BYTE_ORDER" is not defined [-Wundef]
 #if __BYTE_ORDER == __LITTLE_ENDIAN
     ^
../string/endian.h:53:7: warning: "__BYTE_ORDER" is not defined [-Wundef]
 #elif __BYTE_ORDER == __BIG_ENDIAN

Using this command fixes the issue, but I do not know if there's a better way to do this. Neither the ./configure nor the Makefile.in seem to hint to any option that might be remotely related to endianness, and the instructions in the main github project page do not mention anything other than the installation path for configure.

  CPPFLAGS="-Wno-error=unused-value" CFLAGS="-D__BYTE_ORDER=__LITTLE_ENDIAN" make linux 

Internal error when assembling a jal instruction

When trying to assemble a file containing only the instruction:

jal x0, 0

I obtain the following error:

$ riscv64-unknown-elf-as -o /tmp/test.o /tmp/test.s
/tmp/test.s: Assembler messages:
/tmp/test.s:1: Fatal error: internal Error, line 720, $(RISCV_PATH)/riscv-gnu-toolchain/src/binutils/gas/config/tc-riscv.c

I believe this is the valid instruction because of this line

I'm using a freshly built riscv-gnu-toolchain.

stimecmp removal

Hi,

Before b85637e
stimecmp was recognized. What's the reason of its removal? It breaks the seL4 port build (and the privileged manual). This register is written in seL4 while executing in S-Mode and mtimecmp isn't writeable there. Any suggestions for alternative implementations?

Thanks,
Hesham

Linux toolchain build failure

I am having issues building the Linux riscv-isa-toolchain on Ubuntu 14.04. Here's the error I'm seeing during the glibc build:

gawk -f ../scripts/gen-as-const.awk ../sysdeps/riscv/nptl/tcb-offsets.sym \
    | gcc -m64 -S -o /home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux/tcb-offsets.hT3 -std=gnu99 -fgnu89-inline -fno-stack-protector -O2 -Wall -Winline -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes       -U_FORTIFY_SOURCE   -I../include -I/home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux/csu  -I/home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux  -I../sysdeps/unix/sysv/linux/riscv/rv64  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/unix/sysv/linux/riscv  -I../sysdeps/unix/sysv/linux/generic  -I../sysdeps/riscv/nptl  -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/riscv  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/riscv/rv64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/riscv/rv64/soft-fp  -I../sysdeps/riscv  -I../sysdeps/init_array  -I../sysdeps/wordsize-64  -I../sysdeps/riscv/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -isystem /home/arun/crash/zephyr/riscv-gnu-toolchain/linux-headers//include  -D_LIBC_REENTRANT -include ../include/libc-symbols.h       -x c - \
        -MD -MP -MF /home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux/tcb-offsets.h.dT -MT '/home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux/tcb-offsets.h.d /home/arun/crash/zephyr/riscv-gnu-toolchain/build-glibc-linux/tcb-offsets.h'
In file included from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:23:0,
                 from <stdin>:1:
../sysdeps/riscv/nptl/tls.h:44:16: error: invalid register name for ‘__thread_self’
 register void* __thread_self asm("tp");
                ^

Missing riscv64-unknown-linux-gnu-cc, and not symlinks

Using the master branch updated today, I get these binaries installed:

-rwxr-xr-x 1 root root 4046136 Nov 22 12:18 riscv64-unknown-linux-gnu-addr2line
-rwxr-xr-x 2 root root 4207904 Nov 22 12:18 riscv64-unknown-linux-gnu-ar
-rwxr-xr-x 2 root root 5502984 Nov 22 12:18 riscv64-unknown-linux-gnu-as
-rwxr-xr-x 2 root root 3005360 Nov 22 12:30 riscv64-unknown-linux-gnu-c++
-rwxr-xr-x 1 root root 3999880 Nov 22 12:18 riscv64-unknown-linux-gnu-c++filt
-rwxr-xr-x 1 root root 2999312 Nov 22 12:30 riscv64-unknown-linux-gnu-cpp
-rwxr-xr-x 1 root root   92488 Nov 22 12:18 riscv64-unknown-linux-gnu-elfedit
-rwxr-xr-x 2 root root 3005360 Nov 22 12:30 riscv64-unknown-linux-gnu-g++
-rwxr-xr-x 2 root root 2995552 Nov 22 12:30 riscv64-unknown-linux-gnu-gcc
-rwxr-xr-x 2 root root 2995552 Nov 22 12:30 riscv64-unknown-linux-gnu-gcc-5.2.0
-rwxr-xr-x 1 root root  139880 Nov 22 12:30 riscv64-unknown-linux-gnu-gcc-ar
-rwxr-xr-x 1 root root  139744 Nov 22 12:30 riscv64-unknown-linux-gnu-gcc-nm
-rwxr-xr-x 1 root root  139760 Nov 22 12:30 riscv64-unknown-linux-gnu-gcc-ranlib
-rwxr-xr-x 1 root root 1995680 Nov 22 12:30 riscv64-unknown-linux-gnu-gcov
-rwxr-xr-x 1 root root 1878096 Nov 22 12:30 riscv64-unknown-linux-gnu-gcov-tool
-rwxr-xr-x 1 root root 3006232 Nov 22 12:30 riscv64-unknown-linux-gnu-gfortran
-rwxr-xr-x 1 root root 4568016 Nov 22 12:18 riscv64-unknown-linux-gnu-gprof
-rwxr-xr-x 4 root root 5588184 Nov 22 12:18 riscv64-unknown-linux-gnu-ld
-rwxr-xr-x 4 root root 5588184 Nov 22 12:18 riscv64-unknown-linux-gnu-ld.bfd
-rwxr-xr-x 2 root root 4078192 Nov 22 12:18 riscv64-unknown-linux-gnu-nm
-rwxr-xr-x 2 root root 4985680 Nov 22 12:18 riscv64-unknown-linux-gnu-objcopy
-rwxr-xr-x 2 root root 5601312 Nov 22 12:18 riscv64-unknown-linux-gnu-objdump
-rwxr-xr-x 2 root root 4207904 Nov 22 12:18 riscv64-unknown-linux-gnu-ranlib
-rwxr-xr-x 1 root root 1269120 Nov 22 12:18 riscv64-unknown-linux-gnu-readelf
-rwxr-xr-x 1 root root 4035424 Nov 22 12:18 riscv64-unknown-linux-gnu-size
-rwxr-xr-x 1 root root 4035320 Nov 22 12:18 riscv64-unknown-linux-gnu-strings
-rwxr-xr-x 2 root root 4985704 Nov 22 12:18 riscv64-unknown-linux-gnu-strip

At least "riscv64-unknown-linux-gnu-cc" is missing, but "-c++" for example is there. I noticed because it is the one tried to be used by default in a project that I am trying to compile.

Also, a very minor issue -- even if some of them could be just symlinks none of the above are, all of them are "hard copies".

C++ exceptions

Right now C++ exceptions don't work, the problem seems to be that they cannot be caught at all and so std::terminate gets called for every throw. I was able to track down the commit that breaks it: b85637e

Relocation truncated to fit: R_RISCV_HI20 despite of XLEN

Synopsis

References to symbols with address higher than 2GiB are unavailable: linker fails with message relocation truncated to fit: R_RISCV_HI20 against symbols with value above or equal to 0x7ffff800 despite of XLEN=32 or XLEN=64.

Simple test

relocation_test.c

/* no access to void variable, only address taking
skip warning: taking address of expression of type ‘void’ */
extern void feedbeef;
int main(int argc, char* argv[]){
  return (unsigned long)&feedbeef != 0x7ffff800UL;
}

abs_def.S

.globl feedbeef
.set feedbeef, 0x7ffff800

Intermediate files

relocation_test.s

    .file   "relocation_test.c"
    .section    .text.startup,"ax",@progbits
    .align  2
    .globl  main
    .type   main, @function
main:
    li  a5,-2147483648
    lui a4,%hi(feedbeef)
    xor a5,a5,-2048
    add a4,a4,%lo(feedbeef)
    li  a0,1
    beq a4,a5,.L4
    ret
.L4:
    li  a0,0
    ret
    .size   main, .-main
    .ident  "GCC: (GNU) 5.2.0"

objdump

relocation_test.o:     file format elf32-littleriscv

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 relocation_test.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .text.startup  00000000 .text.startup
0000001c l       .text.startup  00000000 .L4
00000000 l    d  .comment   00000000 .comment
00000000 g     F .text.startup  00000024 main
00000000         *UND*  00000000 feedbeef



Disassembly of section .text.startup:

00000000 <main>:
   0:   800007b7            lui a5,0x80000
   4:   00000737            lui a4,0x0
            4: R_RISCV_HI20 feedbeef
   8:   8007c793            xori    a5,a5,-2048
   c:   00070713            mv  a4,a4
            c: R_RISCV_LO12_I   feedbeef
  10:   00100513            li  a0,1
  14:   00f70463            beq a4,a5,1c <.L4>
            14: R_RISCV_BRANCH  .L4
  18:   00008067            ret

0000001c <.L4>:
  1c:   00000513            li  a0,0
  20:   00008067            ret
abs_def.o:     file format elf32-littleriscv

SYMBOL TABLE:
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
7ffff800 g       *ABS*  00000000 feedbeef

ld error

relocation_test.o: In function `main':
relocation_test.c:(.text.startup+0x4): relocation truncated to fit: R_RISCV_HI20 against symbol `feedbeef' defined in *ABS* section in a.out

Root cause

Expression VALID_UTYPE_IMM (RISCV_CONST_HIGH_PART (value)) is false if value >= 0x7ffff800U in binutils/bfd/elfnn-riscv.c@11c69401b1225965d9929f0ba4018deaca5ea0b9 (1485)

/* Emplace a static relocation.  */

static bfd_reloc_status_type
perform_relocation (const reloc_howto_type *howto,
            const Elf_Internal_Rela *rel,
            bfd_vma value,
            asection *input_section,
            bfd *input_bfd,
            bfd_byte *contents)
{
  ...
  switch (ELFNN_R_TYPE (rel->r_info))
    {
    case R_RISCV_HI20:
    case R_RISCV_TPREL_HI20:
    case R_RISCV_PCREL_HI20:
    case R_RISCV_GOT_HI20:
    case R_RISCV_TLS_GOT_HI20:
    case R_RISCV_TLS_GD_HI20:
      if (!VALID_UTYPE_IMM (RISCV_CONST_HIGH_PART (value)))
        return bfd_reloc_overflow;
      value = ENCODE_UTYPE_IMM (RISCV_CONST_HIGH_PART (value));
      break;
    ...
   }
  ...
}

Need to check similar cases.

GCC emits some slow integer/float conversions

The following C program

#define defconv(in, out)                        \  
    out in ## 2 ## out(in i) {                  \  
      union {                                   \  
        in i;                                   \  
        out o;                                  \  
      } conv;                                   \  
                                                \  
      conv.i = i;                               \  
      return conv.o;                            \  
    }  

defconv(long, double)  
defconv(double, long)  
defconv(int, float)  
defconv(float, int)  

emits some good int/float conversions, and some bad ones

palmer.dabbelt a5 riscv-gnu-toolchain-74 $ riscv64-unknown-linux-gnu-gcc test.c -c -o test.o -O3 
palmer.dabbelt a5 riscv-gnu-toolchain-74 $ riscv64-unknown-linux-gnu-objdump -d test.o

test.o:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <long2double>:
   0:   f2050553                fmv.d.x fa0,a0
   4:   00008067                ret

0000000000000008 <double2long>:
   8:   ff010113                addi    sp,sp,-16
   c:   00a13427                fsd     fa0,8(sp)
  10:   00813503                ld      a0,8(sp)
  14:   01010113                addi    sp,sp,16
  18:   00008067                ret

000000000000001c <int2float>:
  1c:   f0050553                fmv.s.x fa0,a0
  20:   00008067                ret

0000000000000024 <float2int>:
  24:   ff010113                addi    sp,sp,-16
  28:   00a12627                fsw     fa0,12(sp)
  2c:   00c12503                lw      a0,12(sp)
  30:   01010113                addi    sp,sp,16
  34:   00008067                ret

I think "222r.combine" is the pass that is combining some of these and not others, but I haven't figured out why yet. This is kind of just a note to myself, but if someone wants to look at it then that would be great!

palmer.dabbelt a5 riscv-gnu-toolchain-74 $ head -n50 test.c.220r.init-regs 

;; Function long2double (long2double, funcdef_no=0, decl_uid=1450, cgraph_uid=0, symbol_order=0)

starting the processing of deferred insns
ending the processing of deferred insns
df_analyze called
starting the processing of deferred insns
ending the processing of deferred insns


long2double  

Dataflow summary:
;;  invalidated by call          0 [zero] 3 [gp] 4 [tp] 5 [t0] 6 [t1] 7 [t2] 10 [a0] 11 [a1] 12 [a2] 13 [a3] 14 [a4] 15 [a5] 16 [a6] 17 [a7] 28 [t3] 29 [t4] 30 [t5] 31 [t6] 32 [ft0] 33 [ft1] 34 [ft2] 35 [ft3] 36 [ft4] 37 [ft5] 38 [ft6] 39 [ft7] 42 [fa0] 43 [fa1] 44 [fa2] 45 [fa3] 46 [fa4] 47 [fa5] 48 [fa6] 49 [fa7] 60 [ft8] 61 [ft9] 62 [ft10] 63 [ft11]
;;  hardware regs used   2 [sp] 64 [arg] 65 [frame]  
;;  regular block artificial uses        2 [sp] 8 [s0] 64 [arg] 65 [frame]
;;  eh block artificial uses     2 [sp] 8 [s0] 64 [arg] 65 [frame]
;;  entry block defs     1 [ra] 2 [sp] 5 [t0] 8 [s0] 10 [a0] 11 [a1] 12 [a2] 13 [a3] 14 [a4] 15 [a5] 16 [a6] 17 [a7] 42 [fa0] 43 [fa1] 44 [fa2] 45 [fa3] 46 [fa4] 47 [fa5] 48 [fa6] 49 [fa7] 64 [arg] 65 [frame]  
;;  exit block uses      1 [ra] 2 [sp] 8 [s0] 42 [fa0] 65 [frame]
;;  regs ever live       10[a0] 42[fa0]
;;  ref usage   r1={1d,1u} r2={1d,2u} r5={1d} r8={1d,2u} r10={1d,1u} r11={1d} r12={1d} r13={1d} r14={1d} r15={1d} r16={1d} r17={1d} r42={2d,2u} r43={1d} r44={1d} r45={1d} r46={1d} r47={1d} r48={1d} r49={1d} r64={1d,1u} r65={1d,2u} r73={1d,1u} r74={1d,1u} 
;;    total ref usage 38{25d,13u,0e} in 4{4 regular + 0 call} insns.
(note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(insn 2 4 3 2 (set (reg/v:DI 74 [ i ])
        (reg:DI 10 a0 [ i ])) test.c:12 132 {*movdi_64bit}
     (expr_list:REG_DEAD (reg:DI 10 a0 [ i ])
        (nil)))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(insn 6 3 10 2 (set (reg:DF 73 [ <retval> ])
        (subreg:DF (reg/v:DI 74 [ i ]) 0)) test.c:12 143 {*movdf_hardfloat_rv64}
     (expr_list:REG_DEAD (reg/v:DI 74 [ i ])
        (nil)))
(insn 10 6 11 2 (set (reg/i:DF 42 fa0)
        (reg:DF 73 [ <retval> ])) test.c:12 143 {*movdf_hardfloat_rv64}
     (expr_list:REG_DEAD (reg:DF 73 [ <retval> ])
        (nil)))
(insn 11 10 0 2 (use (reg/i:DF 42 fa0)) test.c:12 -1
     (nil))

;; Function double2long (double2long, funcdef_no=1, decl_uid=1457, cgraph_uid=1, symbol_order=1)

starting the processing of deferred insns
ending the processing of deferred insns
df_analyze called
starting the processing of deferred insns
ending the processing of deferred insns


double2long
palmer.dabbelt a5 riscv-gnu-toolchain-74 $ head -n60 test.c.222r.combine 

;; Function long2double (long2double, funcdef_no=0, decl_uid=1450, cgraph_uid=0, symbol_order=0)

starting the processing of deferred insns
ending the processing of deferred insns
df_analyze called
insn_cost 2: 4
insn_cost 6: 12
insn_cost 10: 4
insn_cost 11: 0
allowing combination of insns 2 and 6
original costs 4 + 12 = 16
replacement cost 4
deferring deletion of insn with uid = 2.
modifying insn i3     6: r73:DF=a0:DF
      REG_DEAD a0:DI
deferring rescan insn with uid = 6.
allowing combination of insns 6 and 10
original costs 4 + 4 = 8
replacement cost 4
deferring deletion of insn with uid = 6.
modifying insn i3    10: fa0:DF=a0:DF
      REG_DEAD a0:DI
deferring rescan insn with uid = 10.
starting the processing of deferred insns
rescanning insn with uid = 10.
ending the processing of deferred insns


long2double

Dataflow summary:
;;  invalidated by call          0 [zero] 3 [gp] 4 [tp] 5 [t0] 6 [t1] 7 [t2] 10 [a0] 11 [a1] 12 [a2] 13 [a3] 14 [a4] 15 [a5] 16 [a6] 17 [a7] 28 [t3] 29 [t4] 30 [t5] 31 [t6] 32 [ft0] 33 [ft1] 34 [ft2] 35 [ft3] 36 [ft4] 37 [ft5] 38 [ft6] 39 [ft7] 42 [fa0] 43 [fa1] 44 [fa2] 45 [fa3] 46 [fa4] 47 [fa5] 48 [fa6] 49 [fa7] 60 [ft8] 61 [ft9] 62 [ft10] 63 [ft11]
;;  hardware regs used   2 [sp] 64 [arg] 65 [frame]
;;  regular block artificial uses        2 [sp] 8 [s0] 64 [arg] 65 [frame]
;;  eh block artificial uses     2 [sp] 8 [s0] 64 [arg] 65 [frame]
;;  entry block defs     1 [ra] 2 [sp] 5 [t0] 8 [s0] 10 [a0] 11 [a1] 12 [a2] 13 [a3] 14 [a4] 15 [a5] 16 [a6] 17 [a7] 42 [fa0] 43 [fa1] 44 [fa2] 45 [fa3] 46 [fa4] 47 [fa5] 48 [fa6] 49 [fa7] 64 [arg] 65 [frame]
;;  exit block uses      1 [ra] 2 [sp] 8 [s0] 42 [fa0] 65 [frame]
;;  regs ever live       10[a0] 42[fa0]
;;  ref usage   r1={1d,1u} r2={1d,2u} r5={1d} r8={1d,2u} r10={1d,1u} r11={1d} r12={1d} r13={1d} r14={1d} r15={1d} r16={1d} r17={1d} r42={2d,2u} r43={1d} r44={1d} r45={1d} r46={1d} r47={1d} r48={1d} r49={1d} r64={1d,1u} r65={1d,2u}   
;;    total ref usage 34{23d,11u,0e} in 2{2 regular + 0 call} insns.
(note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 4 3 2 NOTE_INSN_DELETED)
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(note 6 3 10 2 NOTE_INSN_DELETED)  
(insn 10 6 11 2 (set (reg/i:DF 42 fa0)
        (reg:DF 10 a0 [ i ])) test.c:12 143 {*movdf_hardfloat_rv64}
     (expr_list:REG_DEAD (reg:DI 10 a0 [ i ])
        (nil)))   
(insn 11 10 0 2 (use (reg/i:DF 42 fa0)) test.c:12 -1
     (nil))

;; Function double2long (double2long, funcdef_no=1, decl_uid=1457, cgraph_uid=1, symbol_order=1)

starting the processing of deferred insns
ending the processing of deferred insns
df_analyze called
insn_cost 2: 4
insn_cost 6: 12
insn_cost 10: 4

Error during multilib build

Hi,
I am trying to build the toolchain with 32-bit and 64-bit support by following the instructions from README file. However, the build failed with the following error:

make[10]: Nothing to be done for `install-data-am'.
make[10]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/32/soft-float/no-atomic/libstdc++-v3'
make[9]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/32/soft-float/no-atomic/libstdc++-v3'
make[8]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/32/soft-float/no-atomic/libstdc++-v3'
make[7]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/libstdc++-v3'
make[6]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/libstdc++-v3'
make[5]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/libstdc++-v3'
make[4]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2/riscv-unknown-linux-gnu/libstdc++-v3'
make[3]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2'
make[2]: *** [install] Error 2
make[2]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain/build-gcc-linux-stage2'
make[1]: *** [stamps/build-gcc-linux-stage2] Error 2
make[1]: Leaving directory `/home/kelkar/tools/riscv-gnu-toolchain'
make: *** [linux] Error 2  

Has it something to do with #46? Can anyone provide some insights?

error: initializer element is not constant (building with gcc 4.9.2)

I'm trying to build riscv-gnu-toolchain (commit c85720a) on raspbian jessie. This is my build script:

sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev \
                     libgmp-dev gawk build-essential bison flex texinfo gperf

sudo mkdir /opt/riscv32i
sudo chown $USER /opt/riscv32i

git clone https://github.com/riscv/riscv-gnu-toolchain riscv-gnu-toolchain-rv32i
cd riscv-gnu-toolchain-rv32i

mkdir build; cd build
../configure --with-xlen=32 --with-arch=I --prefix=/opt/riscv32i
make

This works fine on Ubuntu 14.04.3 LTS with gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4, but on raspbian jessie with gcc (Raspbian 4.9.2-10) 4.9.2 I get the following error:

/bin/bash ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd -I. -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/../include  -DHAVE_riscv_elf32_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec  -DBINDIR='"/opt/riscv32i/bin"'  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT elfxx-riscv.lo -MD -MP -MF .deps/elfxx-riscv.Tpo -c -o elfxx-riscv.lo /home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd -I. -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd -I/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/../include -DHAVE_riscv_elf32_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -DBINDIR=\"/opt/riscv32i/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT elfxx-riscv.lo -MD -MP -MF .deps/elfxx-riscv.Tpo -c /home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c -o elfxx-riscv.o
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:252:3: warning: left shift count >= width of type
   HOWTO (R_RISCV_CALL,   /* type */
   ^
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:252:3: error: initializer element is not constant
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:252:3: error: (near initialization for ‘howto_table[18].dst_mask’)
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:268:3: warning: left shift count >= width of type
   HOWTO (R_RISCV_CALL_PLT,  /* type */
   ^
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:268:3: error: initializer element is not constant
/home/pi/riscv-gnu-toolchain-rv32i/build/src/binutils/bfd/elfxx-riscv.c:268:3: error: (near initialization for ‘howto_table[19].dst_mask’)
Makefile:1607: recipe for target 'elfxx-riscv.lo' failed
make[5]: *** [elfxx-riscv.lo] Error 1

PIC regression

Commit b85637e breaks position-independent code.

For example, consider the following excerpt from __libc_start_main() in glibc/csu/libc-start.c:

  /* Call the initializer of the program, if any.  */
#ifdef SHARED
  if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
    GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
#endif

Here is the corresponding disassembly of libc-2.21.so (64-bit version):

  /* Call the initializer of the program, if any.  */
#ifdef SHARED
  if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
   1f13c:       00000797                auipc   a5,0x0
   1f140:       ec478793                addi    a5,a5,-316 # 1f000 <set_regs+0x5d0>
   1f144:       0007a403                lw      s0,0(a5)
   1f148:       00247413                andi    s0,s0,2
   1f14c:       06041c63                bnez    s0,1f1c4 <__libc_start_main+0xe8>
...
    GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
   1f1c4:       00813703                ld      a4,8(sp)
   1f1c8:       0c87b783                ld      a5,200(a5)
   1f1cc:       000f5517                auipc   a0,0xf5
   1f1d0:       c2c50513                addi    a0,a0,-980 # 113df8 <xdr_zero+0x28>
   1f1d4:       00073583                ld      a1,0(a4)
   1f1d8:       000780e7                jalr    a5
#endif

Notice that the global variable _dl_debug_mask is being referenced using address 0x1f000 (0x2000044000 at runtime), which is clearly wrong as it points to the text segment. This leads to the branch being incorrectly taken and, shortly thereafter, the indirect dl_debug_printf() call jumping to a nonsensical PC (0xf95ff06f6bc120ee).

For comparison, here is its counterpart from the preceding commit, which has been confirmed to work:

#ifdef SHARED
  if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
   1f7cc:       00128797                auipc   a5,0x128
   1f7d0:       ed47b783                ld      a5,-300(a5) # 1476a0 <_GLOBAL_OFFSET_TABLE_+0x108>
   1f7d4:       0007a403                lw      s0,0(a5)
   1f7d8:       00247413                andi    s0,s0,2
   1f7dc:       06041c63                bnez    s0,1f854 <__libc_start_main+0xe8>
...
    GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
   1f854:       00813703                ld      a4,8(sp)
   1f858:       0c87b783                ld      a5,200(a5)
   1f85c:       000f5517                auipc   a0,0xf5
   1f860:       c2c50513                addi    a0,a0,-980 # 114488 <xdr_zero+0x28>
   1f864:       00073583                ld      a1,0(a4)
   1f868:       000780e7                jalr    a5
#endif

The crucial difference is the GOT access.

Text and data in the same segement

This isn't a bug per se, but I thought I'd check to see if it was intentional. It looks like the text and data sections get placed into the same ELF segment. On other architectures, the text and data sections typically go into separate ELF segments.

readelf -l on RISC-V

   02     .interp .note.ABI-tag .dynamic .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt .plt .text .rodata .eh_frame_hdr .eh_frame .init_array .fini_array .jcr .got .sdata .bss 

readelf -l on MIPS:

   03     .interp .note.ABI-tag .reginfo .dynamic .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.plt .init .text .fini .rodata .eh_frame .plt 
   04     .ctors .dtors .jcr .got.plt .data .rld_map .got .sdata .bss 

readelf -l on x86-64:

   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 
   03     .init_array .fini_array .jcr .dynamic .got .got.plt .data .bss 

readelf -l on aarch64:

   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame 
   03     .init_array .fini_array .jcr .dynamic .got .got.plt .data .bss 

gas assertion with oversized constants

Generating constants larger than 64 bits causes gas to assert

palmer.dabbelt a5 build-binutils-newlib $ cat test.S
li x1, 0xffffffffffffffff
li x1, 0x1ffffffffffffffff

palmer.dabbelt a5 build-binutils-newlib $ riscv64-unknown-elf-gcc test.S -c
test.S: Assembler messages:
test.S:2: Internal error!
Assertion failure in load_const at /scratch/palmer.dabbelt/work/kosta-buildbot/rocket-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/config/tc-riscv.c line 900.
Please report this bug.

The call is coming from macro() in tc-riscv.c:

      if (imm_expr->X_op == O_constant)
        load_const (rd, imm_expr);

Unable to build following instructions on readme page due to possible website problem.

After installing a bunch of undisclosed dependencies, I was finally able to execute:

./configure --prefox=/Volumes/workspace/opt/riscv
make

After a moderate amount of text output, it fails with the following:

patching file libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
patching file libsanitizer/sanitizer_common/sanitizer_linux.cc
mv src/gcc.tmp src/gcc
mkdir -p src
rm -rf src/original-newlib src/newlib-*
cd src && curl ftp://sourceware.org/pub/newlib/newlib-1.18.0.tar.gz | tar zx
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to sourceware.org port 21: Connection refused
mv src/newlib-1.18.0 src/original-newlib
mv: rename src/newlib-1.18.0 to src/original-newlib: No such file or directory
make: *** [src/original-newlib] Error 1

In the interests of maximizing the liklihood of reproducible builds, is it please possible to vendor your dependencies? It'd make getting started substantially easier. Thanks!

Unnecessary instructions generated for 16/8 bit integer calculations

Consider this code:

int16_t i16_ret(const int16_t *arr, unsigned int arr_len) {
  int16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  return sum;
}

The current riscv-gcc with -O3 generates the following:

00000000 <i16_ret>:
   0: 02058863            beqz  a1,30 <.L4>
   4: 00159593            slli  a1,a1,0x1
   8: 00050793            mv  a5,a0
   c: 00b505b3            add a1,a0,a1
  10: 00000513            li  a0,0

00000014 <.L3>:
  14: 0007d703            lhu a4,0(a5)
  18: 00278793            addi  a5,a5,2
  1c: 00e50533            add a0,a0,a4
  20: 01051513            slli  a0,a0,0x10
  24: 41055513            srai  a0,a0,0x10
  28: fef596e3            bne a1,a5,14 <.L3>
  2c: 00008067            ret

00000030 <.L4>:
  30: 00000513            li  a0,0
  34: 00008067            ret

Note the slli/srai pair before the branch. It looks like the compiler is trying to truncate the upper 16 bit of the result or sign-extend it. It's not too bad in that case, but being part of the loop hurts performance.

However the compiler does the same even in cases where it wouldn't be needed:

void i16_mem(const int16_t *arr, unsigned int arr_len, int16_t *out) {
  int16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  *out = sum;
}

Compiles to (-O3 again):

00000038 <i16_mem>:
  38: 02058863            beqz  a1,68 <.L10>
  3c: 00159593            slli  a1,a1,0x1
  40: 00b505b3            add a1,a0,a1
  44: 00000793            li  a5,0

00000048 <.L9>:
  48: 00055703            lhu a4,0(a0)
  4c: 00250513            addi  a0,a0,2
  50: 00e787b3            add a5,a5,a4
  54: 01079793            slli  a5,a5,0x10
  58: 4107d793            srai  a5,a5,0x10
  5c: fea596e3            bne a1,a0,48 <.L9>

00000060 <.L8>:
  60: 00f61023            sh  a5,0(a2)
  64: 00008067            ret

00000068 <.L10>:
  68: 00000793            li  a5,0
  6c: ff5ff06f            j 60 <.L8>

Again there's a slli/srai pair. Since the result is stored using a sh, it is not needed though.

When using unsigned ints, the compiler generates a slli/srli pair, but only with -O3. Using -O0 unsigned ints work fine, signed ints still have the problem though.

I also tried with 8 bit integers and got similar results, see below. The problem persists since quite some time, the dumps are from a recent compiler version though (781d50a). Compilers for other targets can optimize this btw., for example or1k llvm/gcc doesn't have this problem.

#include <stdint.h>


// O0:  slli/srli lh/lhu/sh
// O3:  slli/srai lhu
int16_t i16_ret(const int16_t *arr, unsigned int arr_len) {
  int16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  return sum;
}

// O0:  slli/srli lh/lhu/sh
// O3:  slli/srai lhu/sh
void i16_mem(const int16_t *arr, unsigned int arr_len, int16_t *out) {
  int16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  *out = sum;
}


// O0:  OK        lhu/lhu/sh
// O3:  slli/srli lhu
uint16_t u16_ret(const uint16_t *arr, unsigned int arr_len) {
  uint16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  return sum;
}

// O0:  OK        lhu/lhu/sh
// O3:  slli/srli lhu/sh
void u16_mem(const uint16_t *arr, unsigned int arr_len, uint16_t *out) {
  uint16_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  *out = sum;
}



// O0:  OK        lb/lbu/sb
// O3:  slli/srai lbu
int8_t i8_ret(const int8_t *arr, unsigned int arr_len) {
  int8_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  return sum;
}

// O0:  OK        lbu/lbu/sb
// O3:  OK        lw/lbu      (heavily unrolled, 8 bit additions vectorized)
uint8_t u8_ret(const uint8_t *arr, unsigned int arr_len) {
  uint8_t sum = 0;
  for (unsigned int i = 0; i < arr_len; i++) {
    sum += arr[i];
  }
  return sum;
}

(bad codegen): Extra shifting with array indexing on RV64

This is a common bad-code generation for RV64, when using an "unsigned int" as an index into an array. This problem does not show up with a signed int index.

int test32ArrayAccess(uint32_t* arr, unsigned int idx) {  
   return arr[idx];
}

Turns into:

slli  a1,a1,0x20  
srli  a1,a1,0x20  
slli  a1,a1,0x2   
add   a0,a0,a1    
lw a0,0(a0)       
ret         

At a minimum, the last two shifts should be combined into a single shift.

signed char gcc bug

Hello,
I've found what I believe to be a bug in the risc-v gcc. As shown in the code below, I define a singed char, however, it is interpreted as unsigned.

void chartest(char *x, char *y) {
  if (*x < *y)
    printf("c: %hhd < %hhd\n", *x, *y);
  else
    printf("c: %hhd > %hhd\n", *x, *y);
}

void uchartest(unsigned char *x, unsigned char *y) {
  if (*x < *y)
    printf("uc: %hhu < %hhu\n", *x, *y);
  else
    printf("uc: %hhu > %hhu\n", *x, *y);
}

int main(int argc, char **argv) {
  {
    char a = -1;
    char b = 1;
    chartest(&a, &b);
  }
  {
    unsigned char a = -1;
    unsigned char b = 1;
    uchartest(&a, &b);
  }
  return 0;
}

The output of the above code compiled on Ubuntu 14.4 w/ gcc 4.9.2 :

$ ./bugtest-native 
c: -1 < 1
uc: 255 > 1

The output when compiled on riscv-gcc and run on spike:

$ spike pk bugtest-spike
c: 255 > 1
uc: 255 > 1

I looked into the assembly produced by riscv-gcc and see that chartest() and uchartest() both treat the arguments as unsigned.

0000000000010140 <chartest>:
   10140:       00054783                lbu     a5,0(a0)
   10144:       0005c603                lbu     a2,0(a1)
   10148:       00078593                mv      a1,a5
   1014c:       00c7e863                bltu    a5,a2,1015c <chartest+0x1c>
   10150:       0001b537                lui     a0,0x1b
   10154:       ca050513                addi    a0,a0,-864 # 1aca0 <__clz_tab+0x110>
   10158:       2ac0006f                j       10404 <printf>
   1015c:       0001b537                lui     a0,0x1b
   10160:       c9050513                addi    a0,a0,-880 # 1ac90 <__clz_tab+0x100>
   10164:       2a00006f                j       10404 <printf>

0000000000010168 <uchartest>:
   10168:       00054783                lbu     a5,0(a0)
   1016c:       0005c603                lbu     a2,0(a1)
   10170:       00078593                mv      a1,a5
   10174:       00c7e863                bltu    a5,a2,10184 <uchartest+0x1c>
   10178:       0001b537                lui     a0,0x1b
   1017c:       cc850513                addi    a0,a0,-824 # 1acc8 <__clz_tab+0x138>
   10180:       2840006f                j       10404 <printf>
   10184:       0001b537                lui     a0,0x1b
   10188:       cb050513                addi    a0,a0,-848 # 1acb0 <__clz_tab+0x120>
   1018c:       2780006f                j       10404 <printf>

If the compiler had generated "lb" instructions on lines 10140 and 10144 instead of "lbu" I would expect the correct behavior.

Missing implementations for pthread_spin_{init,destroy}

I am not able to compile the following code:

$ cat pthread_spin_test.c 
#include <pthread.h>

int main ()
{
  pthread_spinlock_t s;
  pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE);
  pthread_spin_lock (&s);
  pthread_spin_unlock (&s);
  pthread_spin_destroy (&s);
  return 0;
}     
$ riscv64-unknown-linux-gnu-gcc pthread_spin_test.c -lpthread
/tmp/cchLMbrw.o: In function `main':
pthread_spin_test.c:(.text+0x1c): undefined reference to `pthread_spin_init'
pthread_spin_test.c:(.text+0x44): undefined reference to `pthread_spin_destroy'
collect2: error: ld returned 1 exit status

I suspect the implementations are missing in ./glibc/sysdeps/riscv/nptl/pthread_spin_{init,destroy}.c. I worked around this issue by making the stubs call pthread_spin_lock_unlock if __riscv_atomic is defined, but I am not sure if this is correct in all cases.

Build error: ‘TARGET_ALIAS’ undeclared (first use in this function)

I'm trying to build the toolchain, but I keep getting the following error message. I suspect it may have something to do with the version of gcc installed on my system, which is fairly new. I'm using GCC 4.9.2.

/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c:224:14: error: ‘TARGET_ALIAS’ undeclared (first use in this function)
     VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
              ^
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c:224:14: note: each undeclared identifier is reported only once for each function it appears in
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c: In function ‘parse_args’:
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c:635:5: error: ‘TARGET_ALIAS’ undeclared (first use in this function)
     TARGET_ALIAS);
     ^
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c:649:44: error: ‘TARGET_CANONICAL’ undeclared (first use in this function)
    fprintf (stderr, _("canonical = %s\n"), TARGET_CANONICAL);
                                            ^
/home/zhehao/programs/research/reference-chip/riscv-tools/riscv-gnu-toolchain/build/src/binutils/gas/as.c:650:43: error: ‘TARGET_CPU’ undeclared (first use in this function)
    fprintf (stderr, _("cpu-type = %s\n"), TARGET_CPU);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.