{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2/issues/4155","repository_url":"https://api.github.com/repos/radare/radare2","labels_url":"https://api.github.com/repos/radare/radare2/issues/4155/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2/issues/4155/comments","events_url":"https://api.github.com/repos/radare/radare2/issues/4155/events","html_url":"https://github.com/radare/radare2/issues/4155","id":135813408,"number":4155,"title":"Linux kernel modules addresses","user":{"login":"codido","id":1302219,"avatar_url":"https://avatars.githubusercontent.com/u/1302219?v=3","gravatar_id":"","url":"https://api.github.com/users/codido","html_url":"https://github.com/codido","followers_url":"https://api.github.com/users/codido/followers","following_url":"https://api.github.com/users/codido/following{/other_user}","gists_url":"https://api.github.com/users/codido/gists{/gist_id}","starred_url":"https://api.github.com/users/codido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codido/subscriptions","organizations_url":"https://api.github.com/users/codido/orgs","repos_url":"https://api.github.com/users/codido/repos","events_url":"https://api.github.com/users/codido/events{/privacy}","received_events_url":"https://api.github.com/users/codido/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/radare/radare2/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/radare/radare2/labels/file-format","name":"file-format","color":"f54b07"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/radare/radare2/milestones/11","html_url":"https://github.com/radare/radare2/milestones/0.10.2","labels_url":"https://api.github.com/repos/radare/radare2/milestones/11/labels","id":1583924,"number":11,"title":"0.10.2","description":"","creator":{"login":"radare","id":917142,"avatar_url":"https://avatars.githubusercontent.com/u/917142?v=3","gravatar_id":"","url":"https://api.github.com/users/radare","html_url":"https://github.com/radare","followers_url":"https://api.github.com/users/radare/followers","following_url":"https://api.github.com/users/radare/following{/other_user}","gists_url":"https://api.github.com/users/radare/gists{/gist_id}","starred_url":"https://api.github.com/users/radare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radare/subscriptions","organizations_url":"https://api.github.com/users/radare/orgs","repos_url":"https://api.github.com/users/radare/repos","events_url":"https://api.github.com/users/radare/events{/privacy}","received_events_url":"https://api.github.com/users/radare/received_events","type":"User","site_admin":false},"open_issues":48,"closed_issues":19,"state":"open","created_at":"2016-02-15T18:10:41Z","updated_at":"2016-03-11T22:13:05Z","due_on":"2016-04-10T22:00:00Z","closed_at":null},"comments":9,"created_at":"2016-02-23T17:54:25Z","updated_at":"2016-03-11T22:34:59Z","closed_at":null,"body":"Linux kernel modules do not have program headers. As a result, the addresses r2 uses are basically absolute offsets in the file, while other tools (e.g. nm) seem to use relative offsets in the section.\r\n\r\nFor example, for the following source file:\r\n```\r\n#include <linux/kernel.h>\r\n#include <linux/module.h>\r\n\r\nint hello_init(void)\r\n{\r\n\treturn 0;\r\n}\r\n\r\nvoid hello_exit(void)\r\n{\r\n}\r\n\r\nmodule_init(hello_init);\r\nmodule_exit(hello_exit);\r\n```\r\n\r\nnm yields:\r\n```\r\n$ nm hello.ko | grep hello\r\n0000000000000010 T hello_exit\r\n0000000000000000 T hello_init\r\n```\r\n\r\nwhile r2 yields:\r\n```\r\n$ r2 -qc 'f~hello' hello.ko \r\nWarning: Cannot initialize program headers\r\nWarning: Cannot initialize dynamic section\r\nWarning: Cannot initialize program headers\r\nWarning: Cannot initialize dynamic section\r\n0x00000070 13 sym.hello_init\r\n0x00000080 11 sym.hello_exit\r\n```\r\n\r\nHeaders (objdump):\r\n```\r\nhello.ko:     file format elf64-x86-64\r\n\r\nSections:\r\nIdx Name          Size      VMA               LMA               File off  Algn\r\n  0 .note.gnu.build-id 00000024  0000000000000000  0000000000000000  00000040  2**2\r\n                  CONTENTS, ALLOC, LOAD, READONLY, DATA\r\n  1 .text         0000001b  0000000000000000  0000000000000000  00000070  2**4\r\n                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE\r\n  2 .text.unlikely 00000000  0000000000000000  0000000000000000  0000008b  2**0\r\n                  CONTENTS, ALLOC, LOAD, READONLY, CODE\r\n  3 __mcount_loc  00000010  0000000000000000  0000000000000000  00000090  2**3\r\n                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA\r\n  4 .modinfo      00000038  0000000000000000  0000000000000000  000000a0  2**3\r\n                  CONTENTS, ALLOC, LOAD, READONLY, DATA\r\n  5 .data         00000000  0000000000000000  0000000000000000  000000d8  2**0\r\n                  CONTENTS, ALLOC, LOAD, DATA\r\n  6 .gnu.linkonce.this_module 00000340  0000000000000000  0000000000000000  00000100  2**6\r\n                  CONTENTS, ALLOC, LOAD, RELOC, DATA, LINK_ONCE_DISCARD\r\n  7 .bss          00000000  0000000000000000  0000000000000000  00000440  2**0\r\n                  ALLOC\r\n  8 .debug_info   000078e5  0000000000000000  0000000000000000  00000440  2**0\r\n                  CONTENTS, RELOC, READONLY, DEBUGGING\r\n  9 .debug_abbrev 000005bc  0000000000000000  0000000000000000  00007d25  2**0\r\n                  CONTENTS, READONLY, DEBUGGING\r\n 10 .debug_aranges 00000050  0000000000000000  0000000000000000  000082e1  2**0\r\n                  CONTENTS, RELOC, READONLY, DEBUGGING\r\n 11 .debug_line   0000078e  0000000000000000  0000000000000000  00008331  2**0\r\n                  CONTENTS, RELOC, READONLY, DEBUGGING\r\n 12 .debug_str    00005044  0000000000000000  0000000000000000  00008abf  2**0\r\n                  CONTENTS, READONLY, DEBUGGING\r\n 13 .comment      0000005a  0000000000000000  0000000000000000  0000db03  2**0\r\n                  CONTENTS, READONLY\r\n 14 .note.GNU-stack 00000000  0000000000000000  0000000000000000  0000db5d  2**0\r\n                  CONTENTS, READONLY\r\n 15 .debug_frame  00000068  0000000000000000  0000000000000000  0000db60  2**3\r\n                  CONTENTS, RELOC, READONLY, DEBUGGING\r\n```"},"comment":{"url":"https://api.github.com/repos/radare/radare2/issues/comments/195585028","html_url":"https://github.com/radare/radare2/issues/4155#issuecomment-195585028","issue_url":"https://api.github.com/repos/radare/radare2/issues/4155","id":195585028,"user":{"login":"alvarofe","id":3474042,"avatar_url":"https://avatars.githubusercontent.com/u/3474042?v=3","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":"2016-03-11T22:34:59Z","updated_at":"2016-03-11T22:34:59Z","body":"it seems i didn't compile it well. Trying the `elf` branch shows the correct output \r\n\r\n```\r\nmac:elf-files alvaro_fe$ r2 foobar.o\r\nWarning: Cannot initialize program headers\r\nWarning: Cannot initialize dynamic section\r\n -- Use 'e' and 't' in Visual mode to edit configuration and track flags.\r\n[0x00000000]> is\r\n[Symbols]\r\nvaddr=0x00000000 paddr=0x00000034 ord=010 fwd=NONE sz=10 bind=GLOBAL type=FUNC name=foo\r\nvaddr=0x00000000 paddr=0x00000034 ord=011 fwd=NONE sz=10 bind=GLOBAL type=FUNC name=bar\r\n```"}}