diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-09-15 23:03:25 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-09-15 23:03:25 +0200 |
| commit | c9ff4f0a2a2cfa31964a307c08f9baa349565bbd (patch) | |
| tree | 780fd5b416c9c8a54b0d7933a70a2d49e4c8d549 /lib/Language/Elna/PrinterWriter.hs | |
| parent | d29012d30e158edc28d4467b69a95b5a3c68f04d (diff) | |
| download | elna-c9ff4f0a2a2cfa31964a307c08f9baa349565bbd.tar.gz | |
Add call pseudo instruction
Diffstat (limited to 'lib/Language/Elna/PrinterWriter.hs')
| -rw-r--r-- | lib/Language/Elna/PrinterWriter.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Language/Elna/PrinterWriter.hs b/lib/Language/Elna/PrinterWriter.hs index d0c1fe3..ff8b9aa 100644 --- a/lib/Language/Elna/PrinterWriter.hs +++ b/lib/Language/Elna/PrinterWriter.hs @@ -211,9 +211,17 @@ riscv32Elf code objectHandle = text , st_name = fromIntegral $ ByteString.length names , st_info = stInfo STB_GLOBAL STT_FUNC } + printEntry = Elf32_Sym + { st_value = 0 + , st_size = 0 + , st_shndx = 0 + , st_other = 0 + , st_name = fromIntegral (ByteString.length names) + 7 + , st_info = stInfo STB_GLOBAL STT_FUNC + } liftIO $ ByteString.hPut objectHandle $ LazyByteString.toStrict encoded - let newResult = ElfHeaderResult (names <> "_start\0") - $ Vector.snoc entries newEntry + let newResult = ElfHeaderResult (names <> "_start\0printi\0") + $ Vector.snoc (Vector.snoc entries newEntry) printEntry pure (newResult, size, updatedRelocations) encodeInstruction (instructions, offset, relocations) instruction = let unresolvedRelocation = case instruction of @@ -227,6 +235,9 @@ riscv32Elf code objectHandle = text | RiscV.Lower12S symbolName _ _ _ <- instructionType -> Just -- R_RISCV_LO12_S $ UnresolvedRelocation (Text.Encoding.encodeUtf8 symbolName) offset 28 + RiscV.CallInstruction symbolName + -> Just -- R_RISCV_CALL_PLT + $ UnresolvedRelocation (Text.Encoding.encodeUtf8 symbolName) offset 19 RiscV.Instruction _ _ -> Nothing encoded = ByteString.Builder.toLazyByteString $ RiscV.instruction instruction |
