{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2/issues/12117","repository_url":"https://api.github.com/repos/radare/radare2","labels_url":"https://api.github.com/repos/radare/radare2/issues/12117/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2/issues/12117/comments","events_url":"https://api.github.com/repos/radare/radare2/issues/12117/events","html_url":"https://github.com/radare/radare2/issues/12117","id":379495384,"node_id":"MDU6SXNzdWUzNzk0OTUzODQ=","number":12117,"title":"Base address of ARM object file is not being set correctly","user":{"login":"asutoshpalai","id":8471682,"node_id":"MDQ6VXNlcjg0NzE2ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/8471682?v=4","gravatar_id":"","url":"https://api.github.com/users/asutoshpalai","html_url":"https://github.com/asutoshpalai","followers_url":"https://api.github.com/users/asutoshpalai/followers","following_url":"https://api.github.com/users/asutoshpalai/following{/other_user}","gists_url":"https://api.github.com/users/asutoshpalai/gists{/gist_id}","starred_url":"https://api.github.com/users/asutoshpalai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asutoshpalai/subscriptions","organizations_url":"https://api.github.com/users/asutoshpalai/orgs","repos_url":"https://api.github.com/users/asutoshpalai/repos","events_url":"https://api.github.com/users/asutoshpalai/events{/privacy}","received_events_url":"https://api.github.com/users/asutoshpalai/received_events","type":"User","site_admin":false},"labels":[{"id":289175147,"node_id":"MDU6TGFiZWwyODkxNzUxNDc=","url":"https://api.github.com/repos/radare/radare2/labels/ARM","name":"ARM","color":"0052cc","default":false},{"id":831927763,"node_id":"MDU6TGFiZWw4MzE5Mjc3NjM=","url":"https://api.github.com/repos/radare/radare2/labels/ELF","name":"ELF","color":"ce3a1c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-11T06:39:50Z","updated_at":"2018-11-13T19:44:12Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Work environment\r\n\r\n| Questions                                            | Answers\r\n|------------------------------------------------------|--------------------\r\n| OS/arch/bits (mandatory)                             | Ubuntu x86 64\r\n| File format of the file you reverse (mandatory)      | ELF\r\n| Architecture/bits of the file (mandatory)            | arm/32\r\n| r2 -v full output, **not truncated** (mandatory)     | rradare2 3.1.0-git 20001 @ linux-x86-64 git.3.0.1-181-g59d7a92 commit: 59d7a92f8c09231c73a197d824d7f001a47c401d build: 2018-11-10__22:14:13\r\n\r\n### Expected behavior\r\nAddresses of functions in an ELF *object file* in r2 should match with the addresses output by `objdump`.\r\n\r\n### Actual behavior\r\nThe addresses produced by r2 are with respect to a base address of `0x08000000`.\r\n\r\n### Steps to reproduce the behavior\r\n\r\nPlease find the test object file attached\r\n\r\n```bash\r\n$ cat test2.c \r\nint add(int a, int b) {\r\n        return a + b;\r\n}\r\n\r\n$ arm-linux-gnueabi-gcc -c test2.c -o test.o\r\n\r\n$ r2 -AA -q -c 'afl' ./test.o\r\nWarning: Cannot initialize program headers\r\nWarning: Cannot initialize dynamic strings\r\nWarning: Cannot initialize dynamic section\r\nInvalid range to find strings 0x64 .. 0x64\r\nWarning: run r2 with -e io.cache=true to fix relocations in disassembly\r\n0x08000034    1 48           entry0\r\n\r\n$ r2 -AA -q -c 'pdf @ entry0' ./test.o -e io.cache=true\r\nWarning: Cannot initialize program headers\r\nWarning: Cannot initialize dynamic strings\r\nWarning: Cannot initialize dynamic section\r\nInvalid range to find strings 0x64 .. 0x64\r\n            ;-- section..text:\r\n            ;-- $a:\r\n            ;-- pc:\r\n            ;-- r15:\r\n/ (fcn) entry0 48\r\n|   entry0 ();\r\n|           ; var int local_ch @ fp-0xc\r\n|           ; var int local_8h @ fp-0x8\r\n|           0x08000034      04b02de5       str fp, [sp, -4]!           ; [01] -r-x section size 48 named .text\r\n|           0x08000038      00b08de2       add fp, sp, 0\r\n|           0x0800003c      0cd04de2       sub sp, sp, 0xc\r\n|           0x08000040      08000be5       str r0, [local_8h]          ; 8\r\n|           0x08000044      0c100be5       str r1, [local_ch]          ; 0xc ; 12\r\n|           0x08000048      08201be5       ldr r2, [local_8h]          ; 8\r\n|           0x0800004c      0c301be5       ldr r3, [local_ch]          ; 0xc ; 12\r\n|           0x08000050      033082e0       add r3, r2, r3\r\n|           0x08000054      0300a0e1       mov r0, r3\r\n|           0x08000058      00d04be2       sub sp, fp, 0\r\n|           0x0800005c      04b09de4       pop {fp}\r\n\\           0x08000060      1eff2fe1       bx lr\r\n\r\n$ arm-linux-gnueabi-objdump -d test.o\r\n\r\ntest.o:     file format elf32-littlearm\r\n\r\n\r\nDisassembly of section .text:\r\n\r\n00000000 <add>:\r\n   0:   e52db004        push    {fp}            ; (str fp, [sp, #-4]!)\r\n   4:   e28db000        add     fp, sp, #0\r\n   8:   e24dd00c        sub     sp, sp, #12\r\n   c:   e50b0008        str     r0, [fp, #-8]\r\n  10:   e50b100c        str     r1, [fp, #-12]\r\n  14:   e51b2008        ldr     r2, [fp, #-8]\r\n  18:   e51b300c        ldr     r3, [fp, #-12]\r\n  1c:   e0823003        add     r3, r2, r3\r\n  20:   e1a00003        mov     r0, r3\r\n  24:   e24bd000        sub     sp, fp, #0\r\n  28:   e49db004        pop     {fp}            ; (ldr fp, [sp], #4)\r\n  2c:   e12fff1e        bx      lr\r\n```\r\n[test.o.zip](https://github.com/radare/radare2/files/2569123/test.o.zip)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/radare/radare2/issues/comments/438409771","html_url":"https://github.com/radare/radare2/issues/12117#issuecomment-438409771","issue_url":"https://api.github.com/repos/radare/radare2/issues/12117","id":438409771,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODQwOTc3MQ==","user":{"login":"alvarofe","id":3474042,"node_id":"MDQ6VXNlcjM0NzQwNDI=","avatar_url":"https://avatars1.githubusercontent.com/u/3474042?v=4","gravatar_id":"","url":"https://api.github.com/users/alvarofe","html_url":"https://github.com/alvarofe","followers_url":"https://api.github.com/users/alvarofe/followers","following_url":"https://api.github.com/users/alvarofe/following{/other_user}","gists_url":"https://api.github.com/users/alvarofe/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarofe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarofe/subscriptions","organizations_url":"https://api.github.com/users/alvarofe/orgs","repos_url":"https://api.github.com/users/alvarofe/repos","events_url":"https://api.github.com/users/alvarofe/events{/privacy}","received_events_url":"https://api.github.com/users/alvarofe/received_events","type":"User","site_admin":false},"created_at":"2018-11-13T19:44:12Z","updated_at":"2018-11-13T19:44:12Z","author_association":"CONTRIBUTOR","body":"This iirc is due to objects file have a default address assigned The rationale behind was (if I am not wrong) to avoid overlaps with pa and handle better relocatable files. After all an object file can be mapped anywhere\r\n\r\nThe commit which introduced this was - b0c6ae4409c5cca4837bc75faa7fcdf5b785daa2"}}
{"actor":{"display_login":"alvarofe"}}