From 7814ec18b095d40af95f362ff668a68915982e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20L=C3=A5ng?= Date: Wed, 11 May 2016 13:39:53 +0200 Subject: hipe_llvm: Allow LLVM-generated constants Since 3.7, LLVM sometimes generates SSE constants in a special constant section with the requisite alignment (".rodata.cst16"). This broke hipe_llvm since it assumed that all constants that were linked from the text section were constants generated by hipe_llvm. As this is the first time alignments larger than 8 have been required, some small changes were required to hipe_consttab and hipe_bifs:alloc_data/2. Note that hipe_bifs:alloc_data/2 still assumes that erl_alloc will provide the requisite alignment. --- lib/hipe/llvm/elf_format.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/hipe/llvm/elf_format.erl') diff --git a/lib/hipe/llvm/elf_format.erl b/lib/hipe/llvm/elf_format.erl index 4155dff7c4..b3c5ecddab 100644 --- a/lib/hipe/llvm/elf_format.erl +++ b/lib/hipe/llvm/elf_format.erl @@ -23,6 +23,8 @@ get_exn_handlers/1, %% Symbols elf_symbols/1, + %% Sections + section_contents/2, %% Main interface read/1 ]). @@ -312,6 +314,11 @@ elf_section(?SHN_ABS, #elf{}) -> abs; elf_section(Index, #elf{sec_idx=SecIdx}) when Index =< tuple_size(SecIdx) -> element(Index, SecIdx). +%% Reads the contents of a section from an object +-spec section_contents(elf_shdr(), elf()) -> binary(). +section_contents(#elf_shdr{offset=Offset, size=Size}, #elf{file=ElfBin}) -> + get_binary_segment(ElfBin, Offset, Size). + %%------------------------------------------------------------------------------ %% Functions to manipulate Symbol Table %%------------------------------------------------------------------------------ -- cgit v1.2.3