* fix generation of addend for R_WASM_FUNCTION_OFFSET_I32 relocations. This

improves code address accuracy for WebAssembly debug line info information.
This commit is contained in:
Nikolay Nikolov 2024-09-11 04:50:30 +03:00
parent c8e4a52428
commit d81170ab23

View File

@ -131,6 +131,7 @@ interface
SegSymIdx: Integer;
SegOfs: qword;
FileSectionOfs: qword;
EncodedLocalsSize: qword;
MainFuncSymbol: TWasmObjSymbol;
CustomSectionIdx: Integer;
constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:longint;Aoptions:TObjSectionOptions);override;
@ -1326,6 +1327,7 @@ implementation
encoded_locals.seek(0);
CopyDynamicArray(encoded_locals,dest,encoded_locals.size);
ObjSection.FileSectionOfs:=dest.size-objsym.offset;
ObjSection.EncodedLocalsSize:=encoded_locals.size;
CopyDynamicArray(ObjSection.Data,dest,codeexprlen);
WriteByte(dest,$0B);
encoded_locals.Free;
@ -1607,7 +1609,10 @@ implementation
message1(asmw_e_illegal_unset_index,FuncSym.Name)
else
WriteUleb(relout,FuncSym.SymbolIndex);
WriteSleb(relout,objrel.Addend+objrel.symbol.address); { addend to add to the address }
if (objrel.Addend+objrel.symbol.address)=0 then
WriteSleb(relout,objrel.Addend+objrel.symbol.address) { addend to add to the address }
else
WriteSleb(relout,objrel.Addend+objrel.symbol.address+TWasmObjSection(objrel.symbol.objsection).EncodedLocalsSize); { addend to add to the address }
end
else if assigned(objrel.symbol) and (objrel.symbol.typ=AT_WASM_GLOBAL) then
begin