<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>13310</bug_id>
          
          <creation_ts>2019-04-27 15:20:40 +0000</creation_ts>
          <short_desc>ELF symbols are off by one byte in the symbol table</short_desc>
          <delta_ts>2019-05-02 16:29:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>2.6.2</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.8</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Francis LB">frlebc</reporter>
          <assigned_to name="Joshua Watt">JPEWhacker</assigned_to>
          <cc>frlebc</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>83664</commentid>
    <comment_count>0</comment_count>
      <attachid>4509</attachid>
    <who name="Francis LB">frlebc</who>
    <bug_when>2019-04-27 15:20:40 +0000</bug_when>
    <thetext>Created attachment 4509
Simple hello world code used for the test, with commands and output showing the problem.

The address of the .text symbols in the .symtab symbol table of ELF binaries built using the toolchain seem to be off by one byte.

Steps to reproduce:
1. Cross-compile hello.c (see attachment) using the toolchain
2. Use $OBJDUMP (arm-poky-linux-gnueabi-objdump) to find the address of &quot;main&quot;
3. Use readelf to find the address of &quot;main&quot; from symtab

Observation: The address from readelf is 1 byte after the address from $OBJDUMP.

Expectation: Both are expected to be equal. In my case, objdump returns address 0x50c and readelf returns 0x50d.

I&apos;m using the yocto 2.6.2 toolchain, on CentOS7 host and ARM cortex A9 target.

I observed the same behavior with other ELF that I built on the same setup. I had an older Morty toolchain already available and it does not show the problem.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83709</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Watt">JPEWhacker</who>
    <bug_when>2019-05-02 15:48:09 +0000</bug_when>
    <thetext>Hello,

It is possible that the program was being compiled as THUMB code instead of ARM code? The arm ABI uses the least significant bit of a branch target to determine if a function is ARM (bit is cleared) or THUMB (bit is set). This allows code ti interlink seamlessly between ARM and THUMB code, but it also means that all the THUMB symbols in a given ELF file be odd number. Note that the actual code doesn&apos;t start at the odd address since the CPU ignore the least significant bit for the purpose of calculating the target address. The arm-poky-linux-gnueabi-objdump program is likely accounting for this when showing you the symbols, while your host readelf (either because it is targeting x86 or because readelf just doesn&apos;t account for it) isn&apos;t not.

I believe the easiest way to verify this is to check for &quot;-mthumb&quot; in $CFLAGS

If that&apos;s the case, than this is expected behaviour and everything is working as it is supposed to.

For reference: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83711</commentid>
    <comment_count>2</comment_count>
    <who name="Francis LB">frlebc</who>
    <bug_when>2019-05-02 16:29:57 +0000</bug_when>
    <thetext>Hello,

You are right. After inspection, my current toolchain does provide the THUMB flag. When removing it, I see addresses being aligned. We can close this issue.

I was not familiar with this thumb mode. Thank you very much for the explanation and reference.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4509</attachid>
            <date>2019-04-27 15:20:40 +0000</date>
            <delta_ts>2019-04-27 15:20:40 +0000</delta_ts>
            <desc>Simple hello world code used for the test, with commands and output showing the problem.</desc>
            <filename>objdump_readelf_results.txt</filename>
            <type>text/plain</type>
            <size>684</size>
            <attacher name="Francis LB">frlebc</attacher>
            
              <data encoding="base64">aGVsbG8uYzoKI2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKCXByaW50ZigiSGVsbG8g
d29ybGQhXG4iKTsKCXJldHVybiAwOwp9CgotLS0tLS0tClt1c2VyQG9zdS1jZW50b3M3IGhlbGxv
XSQgc291cmNlIGVudmlyb25tZW50LXNldHVwLWNvcnRleGE5dDJoZi1uZW9uLXBva3ktbGludXgt
Z251ZWFiaQpbdXNlckBvc3UtY2VudG9zNyBoZWxsb10kICRDQyBoZWxsby5jIC1vIGhlbGxvClt1
c2VyQG9zdS1jZW50b3M3IGhlbGxvXSQgJE9CSkRVTVAgLS1zeW1zIGhlbGxvIHwgZ3JlcCBtYWlu
CjAwMDAwMDAwICAgICAgIEYgKlVORCoJMDAwMDAwMDAgICAgICAgICAgICAgIF9fbGliY19zdGFy
dF9tYWluQEBHTElCQ18yLjQKMDAwMDA1MGMgZyAgICAgRiAudGV4dAkwMDAwMDAxOCAgICAgICAg
ICAgICAgbWFpbgpbdXNlckBvc3UtY2VudG9zNyBoZWxsb10kIHJlYWRlbGYgLS1zeW1zIGhlbGxv
IHwgZ3JlcCBtYWluCiAgICAgNjogMDAwMDAwMDAgICAgIDAgRlVOQyAgICBHTE9CQUwgREVGQVVM
VCAgVU5EIF9fbGliY19zdGFydF9tYWluQEdMSUJDXzIuNCAoMikKICAgMTAzOiAwMDAwMDAwMCAg
ICAgMCBGVU5DICAgIEdMT0JBTCBERUZBVUxUICBVTkQgX19saWJjX3N0YXJ0X21haW5AQEdMSUJD
XwogICAxMTI6IDAwMDAwNTBkICAgIDI0IEZVTkMgICAgR0xPQkFMIERFRkFVTFQgICAxMyBtYWlu
</data>

          </attachment>
      

    </bug>

</bugzilla>