<div dir="ltr"><div dir="ltr" class="gmail_msg">One option for detecting arm/thumb is to look at the LSB of the symbol addresses (<span style="color:rgb(33,33,33);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:13px;line-height:1.5">SymbolRef::SF_Thumb flag) </span><span style="line-height:1.5">what specifies the instruction set for the (beginning of the) function. It will work more or less for stripped object files as well based on the symbols in the dynsym section. I think the disassembler in the Mach-O part of objdump (same binary different code path) already solves the problem this way.</span></div><div dir="ltr" class="gmail_msg"><span style="line-height:1.5"><br></span></div><div class="gmail_msg"><span style="line-height:1.5">Tamas</span></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Sun, Sep 18, 2016 at 12:20 AM Michael Spencer via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_msg"><div class="m_-7260184684518941047m_-5242973623001315396gmail_signature gmail_msg">On Fri, Sep 16, 2016 at 2:51 PM, Hemant Kulkarni <span dir="ltr" class="gmail_msg"><<a href="mailto:khemant@codeaurora.org" class="gmail_msg" target="_blank">khemant@codeaurora.org</a>></span> wrote:<br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US" class="gmail_msg"><div class="gmail_msg"><p class="MsoNormal gmail_msg">Hi,<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">The llvm-objdump tool at the moment disassembles ARM ELF binary but with lot of extra user supplied data<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p style="margin-left:38.25pt" class="gmail_msg"><u class="gmail_msg"></u><span style="font-family:symbol" class="gmail_msg"><span class="gmail_msg">·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"times new roman"" class="gmail_msg">         </span></span></span><u class="gmail_msg"></u>The triple supplied on the command line for tools has to be be correct (ARM, thumb etc)<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p style="margin-left:38.25pt" class="gmail_msg"><u class="gmail_msg"></u><span style="font-family:symbol" class="gmail_msg"><span class="gmail_msg">·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"times new roman"" class="gmail_msg">         </span></span></span><u class="gmail_msg"></u>The ELF file cannot have mix of ARM and thumb<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p style="margin-left:38.25pt" class="gmail_msg"><u class="gmail_msg"></u><span style="font-family:symbol" class="gmail_msg"><span class="gmail_msg">·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"times new roman"" class="gmail_msg">         </span></span></span><u class="gmail_msg"></u>There is no direct way of using it such as llvm-objdump –d elf_file. This works for architectures such as Hexagon, X86 etc.<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">Is there a way to enhance the tool to make the use more friendly by removing the need to specify these extra option on command line since it is possible to find the information in the file.<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">The ELF file for arm does not have any field that can be easily inspected to see if the file of type ET_ARM is either a thumb only binary, ARM only binary or a mix. There is however an optional ARM specific section .ARM.attributes that can contain CPU and architecture information such as ISA in use. BFD and gold linker use this section while linking to find any incompatibilities and then emit out a merged (as per ARM ABI extensions) section in final binary. <u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">Any ideas to add this functionality to the without completely redesigning the llvm-objdump will be appreciated. There is already a patch that uses data from ELF file to try doing this. <u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">It is at <a href="https://reviews.llvm.org/D24636" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24636</a><u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">Thanks,<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><br class="gmail_msg"></p></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">objdump is currently in a pretty bad state. The disassembler was basically ripped from llvm-mc and has been hacked on since without needed refactoring. I feel that at this point we need to stop and restructure it before throwing more complexity onto the pile.</div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="m_-7260184684518941047m_-5242973623001315396gmail_signature gmail_msg">- Michael Spencer</div></div><div class="gmail_msg"> </div></div></div></div>
_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
</blockquote></div></div>