aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/llvm/hipe_llvm_main.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-05-09 12:53:05 +0200
committerMagnus Lång <[email protected]>2016-05-09 13:25:52 +0200
commit56ec17296fb350f1eed5486b8d9b575be5afb7a8 (patch)
tree4b8783272c71cb5ab44212bb608cb9e66b5d2972 /lib/hipe/llvm/hipe_llvm_main.erl
parentbeead8e0e29ff6e62f5044f590665d7e02229469 (diff)
downloadotp-56ec17296fb350f1eed5486b8d9b575be5afb7a8.tar.gz
otp-56ec17296fb350f1eed5486b8d9b575be5afb7a8.tar.bz2
otp-56ec17296fb350f1eed5486b8d9b575be5afb7a8.zip
hipe: Remove runtime elf_format class switching
The elf_format module was written in such a way that some of the customisation to ELF-32 vs ELF-64 was made at compile-time and some of it at run-time. As such it was not actually possible to read 32-bit files with a module compiled for 64-bit support, or vice versa. As the run-time selection uses some process dictionary ugliness, it was removed, shifting all the customisation to be compile-time.
Diffstat (limited to 'lib/hipe/llvm/hipe_llvm_main.erl')
-rw-r--r--lib/hipe/llvm/hipe_llvm_main.erl26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/hipe/llvm/hipe_llvm_main.erl b/lib/hipe/llvm/hipe_llvm_main.erl
index ac1f49c73b..9e025929b5 100644
--- a/lib/hipe/llvm/hipe_llvm_main.erl
+++ b/lib/hipe/llvm/hipe_llvm_main.erl
@@ -24,8 +24,6 @@ rtl_to_native(MFA, RTL, Roots, Options) ->
%% Extract information from object file
%%
ObjBin = open_object_file(ObjectFile),
- %% Read and set the ELF class
- elf_format:set_architecture_flag(ObjBin),
%% Get labels info (for switches and jump tables)
Labels = elf_format:get_rodata_relocs(ObjBin),
{Switches, Closures} = get_tables(ObjBin),
@@ -278,14 +276,8 @@ get_sdescs(Elf) ->
_LiveRootCount:(?bits(?SP_LIVEROOTCNT_SIZE))/integer-little, % Skip
Roots/binary>> = NoteGC_bin,
LiveRoots = get_liveroots(Roots, []),
- %% Extract information about the safe point addresses:
- SPOffs =
- case elf_format:is64bit() of
- true -> %% Find offsets in ".rela.note.gc":
- elf_format:get_rela_addends(RelaNoteGC);
- false -> %% Find offsets in SPAddrs (in ".note.gc"):
- get_spoffs(SPAddrs, [])
- end,
+ %% Extract the safe point offsets:
+ SPOffs = get_reloc_addends(SPAddrs, RelaNoteGC),
%% Extract Exception Handler labels:
ExnHandlers = elf_format:get_exn_handlers(Elf),
%% Combine ExnHandlers and Safe point addresses (return addresses):
@@ -301,12 +293,14 @@ get_liveroots(<<Root:?bits(?LR_STKINDEX_SIZE)/integer-little,
MoreRoots/binary>>, Acc) ->
get_liveroots(MoreRoots, [Root | Acc]).
-%% @doc Extracts a bunch of integers (safepoint offsets) from a binary. Returns
-%% a tuple as need for stack descriptors.
-get_spoffs(<<>>, Acc) ->
- lists:reverse(Acc);
-get_spoffs(<<SPOff:?bits(?SP_ADDR_SIZE)/integer-little, More/binary>>, Acc) ->
- get_spoffs(More, [SPOff | Acc]).
+-ifdef(BIT32).
+%% ELF32 x86 uses implicit addends.
+get_reloc_addends(Table, _Relocs) ->
+ [Add || <<Add:?bits(?SP_ADDR_SIZE)/little>> <= Table].
+-else.
+%% ELF64 x64 uses explicit addends.
+get_reloc_addends(_Table, Relocs) -> elf_format:get_rela_addends(Relocs).
+-endif.
combine_ras_and_exns(_, [], Acc) ->
lists:reverse(Acc);