mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 20:49:09 +02:00
+ wasm internal linker: implemented R_WASM_FUNCTION_OFFSET_I32 relocations
This commit is contained in:
parent
b679f8bc06
commit
3fddae4a40
@ -97,6 +97,7 @@ interface
|
|||||||
{ used during linking }
|
{ used during linking }
|
||||||
FuncType: TWasmFuncType;
|
FuncType: TWasmFuncType;
|
||||||
ExeTypeIndex: Integer;
|
ExeTypeIndex: Integer;
|
||||||
|
IsFunctionOffsetI32: Boolean;
|
||||||
|
|
||||||
constructor CreateTypeIndex(ADataOffset:TObjSectionOfs; ATypeIndex: Integer);
|
constructor CreateTypeIndex(ADataOffset:TObjSectionOfs; ATypeIndex: Integer);
|
||||||
constructor CreateFuncType(ADataOffset:TObjSectionOfs; AFuncType: TWasmFuncType);
|
constructor CreateFuncType(ADataOffset:TObjSectionOfs; AFuncType: TWasmFuncType);
|
||||||
@ -4294,6 +4295,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
ObjReloc:=TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_ABSOLUTE);
|
ObjReloc:=TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_ABSOLUTE);
|
||||||
ObjReloc.Addend:=RelocAddend;
|
ObjReloc.Addend:=RelocAddend;
|
||||||
|
ObjReloc.IsFunctionOffsetI32:=True;
|
||||||
ObjSec.ObjRelocations.Add(ObjReloc);
|
ObjSec.ObjRelocations.Add(ObjReloc);
|
||||||
end;
|
end;
|
||||||
R_WASM_SECTION_OFFSET_I32:
|
R_WASM_SECTION_OFFSET_I32:
|
||||||
@ -4665,15 +4667,27 @@ implementation
|
|||||||
case objsym.typ of
|
case objsym.typ of
|
||||||
AT_FUNCTION:
|
AT_FUNCTION:
|
||||||
begin
|
begin
|
||||||
if objsym.LinkingData.ExeFunctionIndex=-1 then
|
if objreloc.IsFunctionOffsetI32 then
|
||||||
internalerror(2024010103);
|
begin
|
||||||
if objsym.LinkingData.ExeIndirectFunctionTableIndex=-1 then
|
{ R_WASM_FUNCTION_OFFSET_I32 }
|
||||||
objsym.LinkingData.ExeIndirectFunctionTableIndex:=AddOrGetIndirectFunctionTableIndex(objsym.LinkingData.ExeFunctionIndex);
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
objsec.Data.seek(objreloc.DataOffset);
|
writeUInt32LE(UInt32(objsym.objsection.MemPos+objreloc.Addend));
|
||||||
writeUInt32LE(UInt32(objsym.LinkingData.ExeIndirectFunctionTableIndex));
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ R_WASM_TABLE_INDEX_I32 }
|
||||||
|
if objsym.LinkingData.ExeFunctionIndex=-1 then
|
||||||
|
internalerror(2024010103);
|
||||||
|
if objsym.LinkingData.ExeIndirectFunctionTableIndex=-1 then
|
||||||
|
objsym.LinkingData.ExeIndirectFunctionTableIndex:=AddOrGetIndirectFunctionTableIndex(objsym.LinkingData.ExeFunctionIndex);
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
writeUInt32LE(UInt32(objsym.LinkingData.ExeIndirectFunctionTableIndex));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
AT_DATA:
|
AT_DATA:
|
||||||
begin
|
begin
|
||||||
|
if objreloc.IsFunctionOffsetI32 then
|
||||||
|
internalerror(2024010602);
|
||||||
objsec.Data.seek(objreloc.DataOffset);
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
writeUInt32LE(UInt32((objsym.offset+objsym.objsection.MemPos)+objreloc.Addend));
|
writeUInt32LE(UInt32((objsym.offset+objsym.objsection.MemPos)+objreloc.Addend));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user