GithubHelp home page GithubHelp logo

loongson / binutils-gdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bminor/binutils-gdb

10.0 10.0 17.0 655.63 MB

Unofficial mirror of sourceware binutils-gdb repository. Updated daily.

Home Page: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git

License: GNU General Public License v2.0

Makefile 14.49% C 47.46% Objective-C 0.01% Shell 0.55% C++ 4.47% Perl 0.11% Emacs Lisp 0.02% D 7.32% Assembly 14.67% DTrace 9.16% Mathematica 0.01% R 0.21% Scheme 0.96% E 0.01% Tcl 0.03% Python 0.17% Awk 0.01% TeX 0.13% XSLT 0.01% Ada 0.23%

binutils-gdb's People

Contributors

amodra avatar andreas-schwab avatar brobecke avatar djdelorierh avatar edelsohn avatar eli-zaretskii avatar fche avatar gingold-adacore avatar hjl-tools avatar hpataxisdotcom avatar ianlancetaylor avatar jakubjelinek avatar jankratochvil avatar jbeulich avatar jim-wilson avatar johntconklin avatar kevinbuettner avatar muller-sourceware-org avatar nickclifton avatar palves avatar perbothner avatar rsandifo avatar shtiek avatar simark avatar t-j-teru avatar tromey avatar vapier avatar vprus avatar vries avatar xdje42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

binutils-gdb's Issues

Faulty behavior regarding const expressions in assembly

Minimized reproducer:

foo:
andi $a0, $a0, (0+(((~((0)))-(((1))<<(0))+1)&(~((0))>>(64-1-(9)))))

This is typical code pattern expanded from Linux's GENMASK(h, l) macro generating bitfield constants.

This breaks with current binutils-gdb main branch:

$ loongarch64-unknown-linux-gnu-gcc -c -o foo.o foo.s
foo.s: Assembler messages:
foo.s:2: Fatal error: Immediate overflow.
format: u10:12
arg: (0+(((~((0)))-(((1))<<(0))+1)&(~((0))>>(64-1-(9)))))

While the LLVM integrated assembler works:

$ clang-16 --target=loongarch64 -fintegrated-as -c -o foo.o foo.s
$ loongarch64-unknown-linux-gnu-objdump -d foo.o

foo.o:     file format elf64-loongarch


Disassembly of section .text:

0000000000000000 <foo>:
   0:   034ffc84        andi            $a0, $a0, 0x3ff

as 汇编器 bug?

以下汇编代码使用as会报错:

.equ EXIT_SUCCESS, 0
.equ STDOUT, 1
.equ SYS_exit, 93
.equ SYS_write, 64

.section .rodata
msg:
    .string "hello, world!\n"
    len = . - msg

.text
    .globl  _start
_start:
    li.w        $a2, $len          # 必须将 $len 写为 0xf
    la.local    $a1, msg
    li.w        $a0, $STDOUT       # 必须将 $STDOUT 写为 1
    li.w        $a7, $SYS_exit     # 必须将 $SYS_exit 写为 64
    syscall     0x0

    li.w        $a0, $EXIT_SUCCESS  # 必须将 $EXIT_SUCCESS 写为 0
    li.w        $a7, $SYS_exit      # 必须将 SYS_exit 写为 93
    syscall     0x0

报错输出如下:

$ as -o hello.o hello.S
hello.S: Assembler messages:
hello.S:14: 错误:no match insn: li.w   $a2,$len
hello.S:16: 错误:no match insn: li.w   $a0,$STDOUT
hello.S:17: 错误:no match insn: li.w   $a7,$SYS_exit
hello.S:20: 错误:no match insn: li.w   $a0,$EXIT_SUCCESS
hello.S:21: 错误:no match insn: li.w   $a7,$SYS_exit

只有按代码中的注释,修改如下,才可通过编译:

$ cat hello.S 
.section .rodata
msg:
    .string "hello, world!\n"
    len = . - msg

.text
    .globl  _start
_start:
    li.w        $a2, 0xf
    la.local    $a1, msg
    li.w        $a0, 1
    li.w        $a7, 64
    syscall     0x0

    li.w        $a0, 0
    li.w        $a7, 93
    syscall     0x0
$ as -o hello.o hello.S
$ ld -o hello hello.o
$ ./hello 
hello, world!

应该是 as 汇编器不支持 .equ 伪指令,同时也不支持使用 len 来计算字符串长度吧?

POP and PUSH relocation types

I found that the relocation types of LoongArch contains pops and pushes, e.g., R_LARCH_SOP_PUSH_PCREL, and in BFD, elfnn-loongarch.c, there is a stack larch_opc_stack. However other architectures do not employ a stack to perform relocations.

Can any one explain the design of these relocation types? Does the order of relocation entries matter in loongarch binaries?

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.