-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: add
R_RISCV_32
and R_RISCV_64
relocations
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Class { | ||
#name : #'R_RISCV_32', | ||
#superclass : #AcRelocation, | ||
#pools : [ | ||
'AcIntLimits' | ||
], | ||
#category : #'ArchC-RISCV-Relocations' | ||
} | ||
|
||
{ #category : #queries } | ||
R_RISCV_32 class >> isValidForInstruction: insn [ | ||
^ insn class == AcInt32 | ||
and: [ insn isa architectureName = 'riscv32' ] | ||
] | ||
|
||
{ #category : #'processing - simplified' } | ||
R_RISCV_32 >> calculateS: s A: a P: p [ | ||
" | ||
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#relocations | ||
32-bit relocation | ||
" | ||
| v | | ||
|
||
v := s + a. | ||
|
||
(v between: UINT32_MIN and: UINT32_MAX) ifFalse:[ ^ AddressOutOfRange ]. | ||
|
||
^ v | ||
] | ||
|
||
{ #category : #'processing - simplified' } | ||
R_RISCV_32 >> fixup: memory at: address with: value [ | ||
| addr | | ||
|
||
addr := ByteArray new: 4. | ||
addr unsignedLongAt: 1 put: value. | ||
|
||
memory replaceFrom: address to: address + 4 - 1 with: addr. | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Class { | ||
#name : #'R_RISCV_64', | ||
#superclass : #AcRelocation, | ||
#pools : [ | ||
'AcIntLimits' | ||
], | ||
#category : #'ArchC-RISCV-Relocations' | ||
} | ||
|
||
{ #category : #queries } | ||
R_RISCV_64 class >> isValidForInstruction: insn [ | ||
^ insn class == AcInt64 | ||
and: [ insn isa architectureName = 'riscv64' ] | ||
] | ||
|
||
{ #category : #'processing - simplified' } | ||
R_RISCV_64 >> calculateS: s A: a P: p [ | ||
" | ||
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#relocations | ||
64-bit relocation | ||
" | ||
| v | | ||
|
||
v := s + a. | ||
|
||
(v between: UINT64_MIN and: UINT64_MAX) ifFalse:[ ^ AddressOutOfRange ]. | ||
|
||
^ v | ||
] | ||
|
||
{ #category : #'processing - simplified' } | ||
R_RISCV_64 >> fixup: memory at: address with: value [ | ||
| addr | | ||
|
||
addr := ByteArray new: 8. | ||
addr unsignedLongLongAt: 1 put: value. | ||
|
||
memory replaceFrom: address to: address + 8 - 1 with: addr. | ||
] |