Comments (4)
Hi,
From PRM, on brcc instruction:
The branch target is computed as the sum of the branch’s 32-bit word-aligned PC plus the 16-bit halfword aligned displacement value given by the signed 9-bit literal operand (rd).
Thus, you need to align your branch targets by using .align pseudo-op:
.text
.global __start
.extAuxRegister AUX_DCCM, 0x18, r|w
.align 4
__start:
mov_s r0, 0x90000000
sr r0, [AUX_DCCM]
mov_s r0,16
mov_s r1,0
mov_s r2,1
.align 4
loop:
add_s r0,r0,1
brlo r0,52,loop
and
.text
.global func
.align 4
func:
breq r5, 0, bug
st r5, [r0, 24]
.align 4
bug:
st r3, [gp, mysda@sda]
Thanks
from toolchain.
Thanks for your explanation, I understand now better what is going on.
However, I still think this is a problem in the tools: not in the linker, but actually in the assembler.
Here the assembler is computing the displacement offset based on the address and its 32bit alignement
of the BRxx instruction. But it is assuming that the 32bit alignement in the object file will be the same that the one after linking. This assumption is false.
The assembler should here force the alignment of the current file to be on 32bit when it is processing this kind of instruction ; or issue a warning if no ".align 4" was found, saying it cannot compute the offset in a reliable way.
I am currently compiling code working fine on MetaWare, and I guess this is the default behavior on this tool as there is no "align" in the source file.
from toolchain.
Thank you for the suggestion, I'll see what can be done with the respect to that warning.
from toolchain.
While trying to find for a workaround, the problem is actually simpler than what I expected:
the assembler is not setting any alignment for .text in object files (2**0
as reported by objdump -h).
This is not the behavior I would expect (e.g. arc-elf32-gcc or arm-xxx-as are setting it to 2**2
).
For instance, adding one ".byte" in some .text section will force the linker to totally unalign the following code, making it impossible to run.
from toolchain.
Related Issues (20)
- GCC/Binutils: Add support for IFUNC
- Investigate the mold linker for ARCv2/v3
- GCC support for ARCv2 ftrace in linux kernel (_mcount)
- fenv.h is not implemented in Newlib HOT 3
- When debugging several projects at once in IDE breakpoints are highlighted as warnings
- IDE: Add support for debugging EMSDP with openocd HOT 1
- Newlib's trigonometric functions won't compile by Clang HOT 2
- debian
- 'mpyd' instruction gets odd register pair as argument HOT 7
- Improve documentation of GCC options for ARCv3
- Newlib cannot be built by Crosstool-NG arc-2023.09 HOT 4
- Binutils from 2023.09 release fail to build with disabled plugins and LTO HOT 1
- binutils objcopy does not understand my elf file created with the metaware toolkit HOT 2
- Newlib for ARC-V uses wrong file-descriptor on write to semihosting HOT 1
- Busybox's hexdump and xxd tools don't work on HS58 if compiled with toolchain 2023.09 HOT 8
- Can the toolchain with arc-elf host as x86_64-w64-mingw32 support Fortran? HOT 1
- Python3 crashing when built for snps_arc32_defconfig HOT 7
- Screen crashing when built for snps_arc32_defconfig HOT 1
- ARC HS6X GCC corrupting store operation addresses when address is a constant whose value exceeds 32 bits HOT 11
- How to debug archs36 dual core simultaneously HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toolchain.