mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-25 03:35:21 +00:00
libelf: add ELF class param to I/O entry points, propagate to scalar accessors and I/O dispatch
This commit is contained in:
@@ -450,7 +450,7 @@ entry_frag(Entry) ->
|
||||
read_elf(File) ->
|
||||
case stdio9:fopen(File, [raw, read]) of
|
||||
{ok, FP} ->
|
||||
case libelf:read_Ehdr(FP) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP) of
|
||||
{ok, Ehdr} -> read_elf(FP, Ehdr);
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
@@ -460,7 +460,7 @@ read_elf(File) ->
|
||||
read_elf(FP, Ehdr) ->
|
||||
case Ehdr of
|
||||
#elf_Ehdr{e_type = ?ET_EXEC, e_entry = Entry} when Entry band 3 =:= 0 ->
|
||||
case libelf:read_PhTab(FP, Ehdr) of
|
||||
case libelf:read_PhTab(?ELFCLASS36, FP, Ehdr) of
|
||||
{ok, PhTab} ->
|
||||
case frags(PhTab) of
|
||||
{ok, Frags} -> {ok, {FP, Entry, Frags}};
|
||||
|
||||
@@ -148,11 +148,11 @@ input_elf(File, FP, Base, Limit, DefMap, UndefMap) ->
|
||||
%% Read ELF symtab =============================================================
|
||||
|
||||
read_elf_symtab(FP, Base, Limit) ->
|
||||
case libelf:read_Ehdr(FP, Base, Limit) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP, Base, Limit) of
|
||||
{ok, Ehdr} ->
|
||||
case libelf:read_ShTab(FP, Base, Limit, Ehdr) of
|
||||
case libelf:read_ShTab(?ELFCLASS36, FP, Base, Limit, Ehdr) of
|
||||
{ok, ShTab} ->
|
||||
case libelf:read_SymTab(FP, Base, Limit, ShTab) of
|
||||
case libelf:read_SymTab(?ELFCLASS36, FP, Base, Limit, ShTab) of
|
||||
{ok, {SymTab, ShNdx}} -> {ok, {ShTab, SymTab, ShNdx}};
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
|
||||
@@ -87,7 +87,7 @@ output_elf_header(Entry, Segments, _GlobalMap, _FileMap, FP, Offset = 0) ->
|
||||
, e_phoff = PhOff
|
||||
, e_phnum = PhNum
|
||||
},
|
||||
case libelf:write_Ehdr(FP, Ehdr) of
|
||||
case libelf:write_Ehdr(?ELFCLASS36, FP, Ehdr) of
|
||||
ok -> {ok, Offset + ?ELF36_EHDR_SIZEOF};
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
@@ -100,7 +100,7 @@ output_phtab(_Entry, Segments, _GlobalMap, _FileMap, FP, Offset = ?ELF36_EHDR_SI
|
||||
|
||||
output_phtab(_Segments = [], _FP, Offset) -> {ok, Offset};
|
||||
output_phtab([#segment{phdr = Phdr} | Segments], FP, Offset) ->
|
||||
case libelf:write_Phdr(FP, Phdr) of
|
||||
case libelf:write_Phdr(?ELFCLASS36, FP, Phdr) of
|
||||
ok -> output_phtab(Segments, FP, Offset + ?ELF36_PHDR_SIZEOF);
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
@@ -374,7 +374,7 @@ ifile_props({Archive, _Name, Offset, Size}) -> {Archive, _Base = Offset, _Limit
|
||||
ifile_props(File) when is_list(File) -> {File, _Base = 0, _Limit = false}.
|
||||
|
||||
input_relocs(_FP, _Base, _Limit, false) -> {ok, []};
|
||||
input_relocs(FP, Base, Limit, Shdr) -> libelf:read_RelaTab(FP, Base, Limit, Shdr).
|
||||
input_relocs(FP, Base, Limit, Shdr) -> libelf:read_RelaTab(?ELFCLASS36, FP, Base, Limit, Shdr).
|
||||
|
||||
input_fini(#frag_input{fp = FP}) ->
|
||||
pdp10_stdio:fclose(FP).
|
||||
|
||||
@@ -419,11 +419,11 @@ read_member_symtab(ArchiveFP, Member) ->
|
||||
end.
|
||||
|
||||
read_member_symtab(FP, Base, Limit) ->
|
||||
case libelf:read_Ehdr(FP, Base, Limit) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP, Base, Limit) of
|
||||
{ok, Ehdr} ->
|
||||
case libelf:read_ShTab(FP, Base, Limit, Ehdr) of
|
||||
case libelf:read_ShTab(?ELFCLASS36, FP, Base, Limit, Ehdr) of
|
||||
{ok, ShTab} ->
|
||||
case libelf:read_SymTab(FP, Base, Limit, ShTab) of
|
||||
case libelf:read_SymTab(?ELFCLASS36, FP, Base, Limit, ShTab) of
|
||||
{ok, {SymTab, _ShNdx}} -> filter_member_symtab(SymTab);
|
||||
{error, _Reason} -> false
|
||||
end;
|
||||
|
||||
@@ -20,28 +20,37 @@
|
||||
|
||||
-module(libelf).
|
||||
|
||||
-export([ read_Ehdr/1
|
||||
, read_Ehdr/3
|
||||
, read_PhTab/2
|
||||
, read_PhTab/4
|
||||
, read_RelaTab/2
|
||||
, read_RelaTab/4
|
||||
, read_ShTab/2
|
||||
, read_ShTab/4
|
||||
, read_SymTab/2
|
||||
, read_SymTab/4
|
||||
-export([ read_Ehdr/2
|
||||
, read_Ehdr/4
|
||||
, read_PhTab/3
|
||||
, read_PhTab/5
|
||||
, read_RelaTab/3
|
||||
, read_RelaTab/5
|
||||
, read_ShTab/3
|
||||
, read_ShTab/5
|
||||
, read_SymTab/3
|
||||
, read_SymTab/5
|
||||
, make_Ehdr/0
|
||||
, write_Ehdr/2
|
||||
, write_Phdr/2
|
||||
, write_Ehdr/3
|
||||
, write_Phdr/3
|
||||
, format_error/1
|
||||
]).
|
||||
|
||||
-include_lib("lib/include/libelf.hrl").
|
||||
-include_lib("lib/include/stdint.hrl").
|
||||
|
||||
-type read_field() :: fun((pdp10_stdio:file())
|
||||
-type elfclass() :: ?ELFCLASS36.
|
||||
-type iodev() :: stdio9:file().
|
||||
|
||||
-export_type([ elfclass/0
|
||||
, iodev/0
|
||||
]).
|
||||
|
||||
-type file() :: {elfclass(), iodev()}.
|
||||
|
||||
-type read_field() :: fun((file())
|
||||
-> {ok, integer()} | {error, {module(), term()}}).
|
||||
-type write_field() :: fun((pdp10_stdio:file(), integer())
|
||||
-type write_field() :: fun((file(), integer())
|
||||
-> ok | {error, term()}).
|
||||
|
||||
-record(record_desc,
|
||||
@@ -51,15 +60,15 @@
|
||||
|
||||
%% I/O of #elf_Ehdr{} ==========================================================
|
||||
|
||||
-spec read_Ehdr(pdp10_stdio:file())
|
||||
-spec read_Ehdr(elfclass(), iodev())
|
||||
-> {ok, #elf_Ehdr{}} | {error, {module(), term()}}.
|
||||
read_Ehdr(FP) ->
|
||||
read_Ehdr(FP, _Base = 0, _Limit = false).
|
||||
read_Ehdr(EC, IoDev) ->
|
||||
read_Ehdr(EC, IoDev, _Base = 0, _Limit = false).
|
||||
|
||||
%% FIXME: take EI_CLASS as parameter
|
||||
-spec read_Ehdr(pdp10_stdio:file(), non_neg_integer(), false | non_neg_integer())
|
||||
-spec read_Ehdr(elfclass(), iodev(), non_neg_integer(), false | non_neg_integer())
|
||||
-> {ok, #elf_Ehdr{}} | {error, {module(), term()}}.
|
||||
read_Ehdr(FP, Base, Limit) ->
|
||||
read_Ehdr(EC, IoDev, Base, Limit) ->
|
||||
FP = {EC, IoDev},
|
||||
case fseek(FP, {bof, Base}) of
|
||||
ok ->
|
||||
case read_record(FP, elf_Ehdr_desc()) of
|
||||
@@ -110,10 +119,10 @@ make_Ehdr() ->
|
||||
, e_shstrndx = 0
|
||||
}.
|
||||
|
||||
%% FIXME: take EI_CLASS as parameter
|
||||
-spec write_Ehdr(pdp10_stdio:file(), #elf_Ehdr{})
|
||||
-spec write_Ehdr(elfclass(), iodev(), #elf_Ehdr{})
|
||||
-> ok | {error, {module(), term()}}.
|
||||
write_Ehdr(FP, Ehdr) ->
|
||||
write_Ehdr(EC, IoDev, Ehdr) ->
|
||||
FP = {EC, IoDev},
|
||||
write_record(FP, Ehdr, elf_Ehdr_desc()).
|
||||
|
||||
elf_Ehdr_desc() ->
|
||||
@@ -305,14 +314,15 @@ check_Ehdr_e_shentsize(Ehdr) ->
|
||||
|
||||
%% I/O of PhTab ================================================================
|
||||
|
||||
-spec read_PhTab(pdp10_stdio:file(), #elf_Ehdr{})
|
||||
-spec read_PhTab(elfclass(), iodev(), #elf_Ehdr{})
|
||||
-> {ok, [#elf_Phdr{}]} | {error, {module(), term()}}.
|
||||
read_PhTab(FP, Ehdr) ->
|
||||
read_PhTab(FP, _Base = 0, _Limit = false, Ehdr).
|
||||
read_PhTab(EC, IoDev, Ehdr) ->
|
||||
read_PhTab(EC, IoDev, _Base = 0, _Limit = false, Ehdr).
|
||||
|
||||
-spec read_PhTab(pdp10_stdio:file(), non_neg_integer(), false | non_neg_integer(), #elf_Ehdr{})
|
||||
-spec read_PhTab(elfclass(), iodev(), non_neg_integer(), false | non_neg_integer(), #elf_Ehdr{})
|
||||
-> {ok, [#elf_Phdr{}]} | {error, {module(), term()}}.
|
||||
read_PhTab(FP, Base, Limit, Ehdr) ->
|
||||
read_PhTab(EC, IoDev, Base, Limit, Ehdr) ->
|
||||
FP = {EC, IoDev},
|
||||
#elf_Ehdr{ e_phoff = PhOff
|
||||
, e_phentsize = PhEntSize
|
||||
, e_phnum = PhNum } = Ehdr,
|
||||
@@ -344,14 +354,15 @@ do_read_PhTab(FP, PhNum, Phdrs) ->
|
||||
|
||||
%% I/O of relocation tables ====================================================
|
||||
|
||||
-spec read_RelaTab(pdp10_stdio:file(), #elf_Shdr{})
|
||||
-spec read_RelaTab(elfclass(), iodev(), #elf_Shdr{})
|
||||
-> {ok, [#elf_Rela{}]} | {error, {module(), term()}}.
|
||||
read_RelaTab(FP, Shdr) ->
|
||||
read_RelaTab(FP, _Base = 0, _Limit = false, Shdr).
|
||||
read_RelaTab(EC, IoDev, Shdr) ->
|
||||
read_RelaTab(EC, IoDev, _Base = 0, _Limit = false, Shdr).
|
||||
|
||||
-spec read_RelaTab(pdp10_stdio:file(), non_neg_integer(), false | non_neg_integer(), #elf_Shdr{})
|
||||
-spec read_RelaTab(elfclass(), iodev(), non_neg_integer(), false | non_neg_integer(), #elf_Shdr{})
|
||||
-> {ok, [#elf_Rela{}]} | {error, {module(), term()}}.
|
||||
read_RelaTab(FP, Base, Limit, Shdr) ->
|
||||
read_RelaTab(EC, IoDev, Base, Limit, Shdr) ->
|
||||
FP = {EC, IoDev},
|
||||
#elf_Shdr{ sh_type = ShType
|
||||
, sh_size = ShSize
|
||||
, sh_offset = ShOffset
|
||||
@@ -396,14 +407,15 @@ do_read_RelaTab(FP, RelaNum, Relas) when RelaNum > 0 ->
|
||||
|
||||
%% I/O of ShTab ================================================================
|
||||
|
||||
-spec read_ShTab(pdp10_stdio:file(), #elf_Ehdr{})
|
||||
-spec read_ShTab(elfclass(), iodev(), #elf_Ehdr{})
|
||||
-> {ok, [#elf_Shdr{}]} | {error, {module(), term()}}.
|
||||
read_ShTab(FP, Ehdr) ->
|
||||
read_ShTab(FP, _Base = 0, _Limit = false, Ehdr).
|
||||
read_ShTab(EC, IoDev, Ehdr) ->
|
||||
read_ShTab(EC, IoDev, _Base = 0, _Limit = false, Ehdr).
|
||||
|
||||
-spec read_ShTab(pdp10_stdio:file(), non_neg_integer(), false | non_neg_integer(), #elf_Ehdr{})
|
||||
-spec read_ShTab(elfclass(), iodev(), non_neg_integer(), false | non_neg_integer(), #elf_Ehdr{})
|
||||
-> {ok, [#elf_Shdr{}]} | {error, {module(), term()}}.
|
||||
read_ShTab(FP, Base, Limit, Ehdr) ->
|
||||
read_ShTab(EC, IoDev, Base, Limit, Ehdr) ->
|
||||
FP = {EC, IoDev},
|
||||
#elf_Ehdr{ e_shoff = ShOff
|
||||
, e_shnum = ShNum0
|
||||
, e_shstrndx = ShStrNdx } = Ehdr,
|
||||
@@ -514,14 +526,15 @@ get_name(_C, [], _Acc) -> {error, {?MODULE, strtab_not_nul_terminated}}.
|
||||
|
||||
%% I/O of SymTab ===============================================================
|
||||
|
||||
-spec read_SymTab(pdp10_stdio:file(), [#elf_Shdr{}])
|
||||
-spec read_SymTab(elfclass(), iodev(), [#elf_Shdr{}])
|
||||
-> {ok, {[#elf_Sym{}],non_neg_integer()}} | {error, {module(), term()}}.
|
||||
read_SymTab(FP, ShTab) ->
|
||||
read_SymTab(FP, _Base = 0, _Limit = false, ShTab).
|
||||
read_SymTab(EC, IoDev, ShTab) ->
|
||||
read_SymTab(EC, IoDev, _Base = 0, _Limit = false, ShTab).
|
||||
|
||||
-spec read_SymTab(pdp10_stdio:file(), non_neg_integer(), false | non_neg_integer(), [#elf_Shdr{}])
|
||||
-spec read_SymTab(elfclass(), iodev(), non_neg_integer(), false | non_neg_integer(), [#elf_Shdr{}])
|
||||
-> {ok, {[#elf_Sym{}],non_neg_integer()}} | {error, {module(), term()}}.
|
||||
read_SymTab(FP, Base, Limit, ShTab) ->
|
||||
read_SymTab(EC, IoDev, Base, Limit, ShTab) ->
|
||||
FP = {EC, IoDev},
|
||||
case find_SymTab(ShTab) of
|
||||
false -> {ok, {[], ?SHN_UNDEF}};
|
||||
{ok, {Shdr, ShNdx}} ->
|
||||
@@ -596,9 +609,10 @@ read_Sym_name(Sym = #elf_Sym{st_name = StName}, StrTab) ->
|
||||
|
||||
read_Phdr(FP) -> read_record(FP, elf_Phdr_desc()).
|
||||
|
||||
-spec write_Phdr(pdp10_stdio:file(), #elf_Phdr{})
|
||||
-spec write_Phdr(elfclass(), iodev(), #elf_Phdr{})
|
||||
-> ok | {error, {module(), term()}}.
|
||||
write_Phdr(FP, Phdr) ->
|
||||
write_Phdr(EC, IoDev, Phdr) ->
|
||||
FP = {EC, IoDev},
|
||||
write_record(FP, Phdr, elf_Phdr_desc()).
|
||||
|
||||
%% FIXME: take EI_CLASS as parameter
|
||||
@@ -698,10 +712,15 @@ do_write_record(_FP, _Fields = [], _Values = []) ->
|
||||
%% I/O of scalar items =========================================================
|
||||
|
||||
read_Addr(FP) -> read_u4(FP).
|
||||
|
||||
read_Half(FP) -> read_u2(FP).
|
||||
|
||||
read_Off(FP) -> read_u4(FP).
|
||||
|
||||
read_Sword(FP) -> read_s4(FP).
|
||||
|
||||
read_Uchar(FP) -> read_u1(FP).
|
||||
|
||||
read_Word(FP) -> read_u4(FP).
|
||||
|
||||
read_u1(FP) ->
|
||||
@@ -710,11 +729,11 @@ read_u1(FP) ->
|
||||
Other -> Other % {ok, _Byte} or {error, _Reason}
|
||||
end.
|
||||
|
||||
read_u2(FP) -> read(FP, 2, fun extint:uint18_from_ext/1).
|
||||
read_u2({?ELFCLASS36, _} = FP) -> read(FP, 2, fun extint:uint18_from_ext/1).
|
||||
|
||||
read_u4(FP) -> read(FP, 4, fun extint:uint36_from_ext/1).
|
||||
read_u4({?ELFCLASS36, _} = FP) -> read(FP, 4, fun extint:uint36_from_ext/1).
|
||||
|
||||
read_s4(FP) -> read(FP, 4, fun sint36_from_ext/1).
|
||||
read_s4({?ELFCLASS36, _} = FP) -> read(FP, 4, fun sint36_from_ext/1).
|
||||
|
||||
sint36_from_ext(Bytes) ->
|
||||
sext:sext(extint:uint36_from_ext(Bytes), 36).
|
||||
@@ -726,35 +745,40 @@ read(FP, N, ConvFun) ->
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
|
||||
write_Addr(FP, UInt36) -> write_u4(FP, UInt36).
|
||||
write_Half(FP, UInt18) -> write_u2(FP, UInt18).
|
||||
write_Off(FP, UInt36) -> write_u4(FP, UInt36).
|
||||
write_Sword(FP, SInt36) -> write_u4(FP, SInt36 band ?UINT36_MAX).
|
||||
write_Uchar(FP, UInt9) -> write_u1(FP, UInt9).
|
||||
write_Word(FP, UInt36) -> write_u4(FP, UInt36).
|
||||
write_Addr(FP, Addr) -> write_u4(FP, Addr).
|
||||
|
||||
write_Half(FP, Half) -> write_u2(FP, Half).
|
||||
|
||||
write_Off(FP, Off) -> write_u4(FP, Off).
|
||||
|
||||
write_Sword(FP, Sword) -> write_u4(FP, Sword band ?UINT36_MAX).
|
||||
|
||||
write_Uchar(FP, Uchar) -> write_u1(FP, Uchar).
|
||||
|
||||
write_Word(FP, Word) -> write_u4(FP, Word).
|
||||
|
||||
write_u1(FP, Uchar) ->
|
||||
fputc(Uchar, FP).
|
||||
|
||||
write_u2(FP, Half) ->
|
||||
write_u2({?ELFCLASS36, _} = FP, Half) ->
|
||||
fputs(extint:uint18_to_ext(Half), FP).
|
||||
|
||||
write_u4(FP, Word) ->
|
||||
write_u4({?ELFCLASS36, _} = FP, Word) ->
|
||||
fputs(extint:uint36_to_ext(Word), FP).
|
||||
|
||||
%% I/O dispatchers =============================================================
|
||||
|
||||
fgetc(IoDev) -> stdio9:fgetc(IoDev).
|
||||
fgetc({?ELFCLASS36, IoDev}) -> stdio9:fgetc(IoDev).
|
||||
|
||||
fputc(Byte, IoDev) -> stdio9:fputc(Byte, IoDev).
|
||||
fputc(Byte, {?ELFCLASS36, IoDev}) -> stdio9:fputc(Byte, IoDev).
|
||||
|
||||
fputs(Bytes, IoDev) -> stdio9:fputs(Bytes, IoDev).
|
||||
fputs(Bytes, {?ELFCLASS36, IoDev}) -> stdio9:fputs(Bytes, IoDev).
|
||||
|
||||
fread(NrBytes, IoDev) -> stdio9:fread(NrBytes, IoDev).
|
||||
fread(NrBytes, {?ELFCLASS36, IoDev}) -> stdio9:fread(NrBytes, IoDev).
|
||||
|
||||
fseek(IoDev, Position) -> stdio9:fseek(IoDev, Position).
|
||||
fseek({?ELFCLASS36, IoDev}, Position) -> stdio9:fseek(IoDev, Position).
|
||||
|
||||
ftell(IoDev) -> stdio9:ftell(IoDev).
|
||||
ftell({?ELFCLASS36, IoDev}) -> stdio9:ftell(IoDev).
|
||||
|
||||
%% Error Formatting ============================================================
|
||||
|
||||
|
||||
@@ -204,11 +204,11 @@ nm1(Opts, File, FP, Base, Limit) ->
|
||||
%% read ELF symtab =============================================================
|
||||
|
||||
read_elf_symtab(FP, Base, Limit) ->
|
||||
case libelf:read_Ehdr(FP, Base, Limit) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP, Base, Limit) of
|
||||
{ok, Ehdr} ->
|
||||
case libelf:read_ShTab(FP, Base, Limit, Ehdr) of
|
||||
case libelf:read_ShTab(?ELFCLASS36, FP, Base, Limit, Ehdr) of
|
||||
{ok, ShTab} ->
|
||||
case libelf:read_SymTab(FP, Base, Limit, ShTab) of
|
||||
case libelf:read_SymTab(?ELFCLASS36, FP, Base, Limit, ShTab) of
|
||||
{ok, {SymTab, _ShNdx}} -> {ok, {ShTab, SymTab}};
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
|
||||
@@ -188,7 +188,7 @@ readelf_file(Opts, File) ->
|
||||
end.
|
||||
|
||||
readelf_ehdr(Opts, FP) ->
|
||||
case libelf:read_Ehdr(FP) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP) of
|
||||
{ok, Ehdr} ->
|
||||
print_ehdr(Opts, Ehdr),
|
||||
readelf_shtab(Opts, FP, Ehdr);
|
||||
@@ -196,7 +196,7 @@ readelf_ehdr(Opts, FP) ->
|
||||
end.
|
||||
|
||||
readelf_shtab(Opts, FP, Ehdr) ->
|
||||
case libelf:read_ShTab(FP, Ehdr) of
|
||||
case libelf:read_ShTab(?ELFCLASS36, FP, Ehdr) of
|
||||
{ok, ShTab} ->
|
||||
print_shtab(Opts, ShTab),
|
||||
print_phtab(Opts, FP, Ehdr),
|
||||
@@ -205,7 +205,7 @@ readelf_shtab(Opts, FP, Ehdr) ->
|
||||
end.
|
||||
|
||||
readelf_symtab(Opts, FP, ShTab) ->
|
||||
case libelf:read_SymTab(FP, ShTab) of
|
||||
case libelf:read_SymTab(?ELFCLASS36, FP, ShTab) of
|
||||
{ok, {SymTab, ShNdx}} ->
|
||||
print_relatab(Opts, FP, SymTab, ShNdx, ShTab),
|
||||
print_symtab(Opts, SymTab, ShNdx, ShTab),
|
||||
@@ -436,7 +436,7 @@ sh_flags([], _I, ShFlags, Mask, Acc) ->
|
||||
|
||||
print_phtab(#options{segments = false}, _FP, _Ehdr) -> ok;
|
||||
print_phtab(Opts, FP, Ehdr) ->
|
||||
case libelf:read_PhTab(FP, Ehdr) of
|
||||
case libelf:read_PhTab(?ELFCLASS36, FP, Ehdr) of
|
||||
{ok, []} ->
|
||||
io:format("There are no program headers in this file.\n\n");
|
||||
{ok, PhTab} ->
|
||||
@@ -538,7 +538,7 @@ print_relatab2([], _FP, _SymTab, _SymTabNdx, _Any = true) ->
|
||||
ok.
|
||||
|
||||
print_relatab(Shdr, FP, SymTab) ->
|
||||
case libelf:read_RelaTab(FP, Shdr) of
|
||||
case libelf:read_RelaTab(?ELFCLASS36, FP, Shdr) of
|
||||
{ok, Relas} ->
|
||||
NrRelas = length(Relas),
|
||||
io:format("Relocation section '~s' at offset 0x~.16b contains ~.10b entr~s:\n",
|
||||
|
||||
@@ -54,7 +54,7 @@ load(Exe, ArgvStrings, EnvStrings) ->
|
||||
end.
|
||||
|
||||
load_fp(FP, ArgvStrings, EnvStrings) ->
|
||||
case libelf:read_Ehdr(FP) of
|
||||
case libelf:read_Ehdr(?ELFCLASS36, FP) of
|
||||
{ok, Ehdr} -> load(FP, Ehdr, ArgvStrings, EnvStrings);
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
@@ -62,7 +62,7 @@ load_fp(FP, ArgvStrings, EnvStrings) ->
|
||||
load(FP, Ehdr, ArgvStrings, EnvStrings) ->
|
||||
case Ehdr#elf_Ehdr.e_type of
|
||||
?ET_EXEC ->
|
||||
case libelf:read_PhTab(FP, Ehdr) of
|
||||
case libelf:read_PhTab(?ELFCLASS36, FP, Ehdr) of
|
||||
{ok, PhTab} -> load(FP, Ehdr, PhTab, ArgvStrings, EnvStrings);
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
, {extint, uint32_to_ext, 1}
|
||||
, {extint, uint64_from_ext, 1}
|
||||
, {extint, uint64_to_ext, 1}
|
||||
, {libelf, read_PhTab, 4}
|
||||
, {libelf, read_PhTab, 5}
|
||||
, {pdp10_opcodes, cpu_device_from_name, 2}
|
||||
, {pdp10_opcodes, models_from_name, 1}
|
||||
, {sim_core, calculate_ea, 5}
|
||||
|
||||
Reference in New Issue
Block a user