{"action":"created","comment":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/135770350","pull_request_review_id":59218488,"id":135770350,"diff_hunk":"@@ -128,13 +137,101 @@ def resolve(self, addr):\n             ret = '!!!'\n         return ret\n \n+    def symbol_plus_offset(self, addr):\n+        ret = None\n+        prevsize = 0\n+        reladdr = self.subtract_load_addr(addr)\n+        elf = self.get_elf(self._bin)\n+        cmd = self.arch_prefix('nm')\n+        if not reladdr or not elf or not cmd:\n+            return ''\n+        ireladdr = int(reladdr, 0)\n+        nm = subprocess.Popen([cmd, '--numeric-sort', '--print-size', elf],\n+                               stdin = subprocess.PIPE,\n+                               stdout = subprocess.PIPE)\n+        for line in iter(nm.stdout.readline, ''):\n+            try:\n+                addr, size, _, name = line.split()\n+            except:\n+                # Size is missing\n+                addr, _, name = line.split()\n+                size = '0'\n+            iaddr = int(addr, 16)\n+            isize = int(size, 16)\n+            if iaddr == ireladdr:\n+                ret = name\n+                break\n+            if iaddr < ireladdr and iaddr + isize >= ireladdr:\n+                offs = ireladdr - iaddr\n+                ret = name + '+' + str(offs)\n+                break\n+            if iaddr > ireladdr and prevsize == 0:\n+                offs = iaddr + ireladdr\n+                ret = prevname + '+' + str(offs)\n+                break\n+            prevsize = size\n+            prevname = name\n+        if ret is None:\n+            ret = ''\n+        nm.terminate()\n+        return ret\n+\n+    def section_plus_offset(self, addr):\n+        ret = None\n+        reladdr = self.subtract_load_addr(addr)\n+        elf = self.get_elf(self._bin)\n+        cmd = self.arch_prefix('objdump')\n+        if not reladdr or not elf or not cmd:\n+            return ''\n+        iaddr = int(reladdr, 0)\n+        objdump = subprocess.Popen([cmd, '--section-headers', elf],\n+                                    stdin = subprocess.PIPE,\n+                                    stdout = subprocess.PIPE)\n+        for line in iter(objdump.stdout.readline, ''):\n+            try:\n+                idx, name, size, vma, lma, offs, algn = line.split()\n+            except:\n+                continue;\n+\t    ivma = int(vma, 16)\n+            isize = int(size, 16)\n+            if ivma == iaddr:","path":"scripts/symbolize.py","position":115,"original_position":115,"commit_id":"38e47d7e2899845dd01d08ae40840459e3903d94","original_commit_id":"38e47d7e2899845dd01d08ae40840459e3903d94","user":{"login":"jbech-linaro","id":6168937,"avatar_url":"https://avatars0.githubusercontent.com/u/6168937?v=4","gravatar_id":"","url":"https://api.github.com/users/jbech-linaro","html_url":"https://github.com/jbech-linaro","followers_url":"https://api.github.com/users/jbech-linaro/followers","following_url":"https://api.github.com/users/jbech-linaro/following{/other_user}","gists_url":"https://api.github.com/users/jbech-linaro/gists{/gist_id}","starred_url":"https://api.github.com/users/jbech-linaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbech-linaro/subscriptions","organizations_url":"https://api.github.com/users/jbech-linaro/orgs","repos_url":"https://api.github.com/users/jbech-linaro/repos","events_url":"https://api.github.com/users/jbech-linaro/events{/privacy}","received_events_url":"https://api.github.com/users/jbech-linaro/received_events","type":"User","site_admin":false},"body":"Isn't this check superfluous? Wouldn't you get the same in the next if check but with offset 0?","created_at":"2017-08-29T12:09:34Z","updated_at":"2017-08-29T12:09:34Z","html_url":"https://github.com/OP-TEE/optee_os/pull/1767#discussion_r135770350","pull_request_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767","_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/135770350"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/1767#discussion_r135770350"},"pull_request":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767"}}},"pull_request":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767","id":137502291,"html_url":"https://github.com/OP-TEE/optee_os/pull/1767","diff_url":"https://github.com/OP-TEE/optee_os/pull/1767.diff","patch_url":"https://github.com/OP-TEE/optee_os/pull/1767.patch","issue_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/1767","number":1767,"state":"open","locked":false,"title":"scripts/symbolize.py: try to resolve abort address to symbol/section[+offset]","user":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars2.githubusercontent.com/u/8288195?v=4","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"body":"```\r\nUse nm and objdump to find the symbol and ELF section that match the\r\naddress reported in the the abort line. This can help debug writes to\r\nread-only data or unaligned accesses to global data, for example.\r\n\r\nIf the address can be resolved to a symbol plus some offset and/or a\r\nsection plus some offset, the abort line is printed again just before\r\nthe call stack with the symbolic information added. Not that the\r\ntranslation cannot be done immediately when the abort line is seen\r\nbecause at this point we don't know the architecture, and we don't have\r\nthe load address of the TA.\r\n\r\nHere is an example (the line added by this patch is marked with >>):\r\n\r\n   User TA data-abort at address 0x1314d0 (write permission fault)\r\n    fsr 0x0000080f  ttbr0 0x0e07a06a  ttbr1 0x0e07406a  cidr 0x1\r\n    cpu #0          cpsr 0x60000030\r\n    r0 0x00000001      r4 0x00102780    r8 0x00000000   r12 0xb736e358\r\n    r1 0x00102724      r5 0x00121e4f    r9 0x00000000    sp 0x001026e0\r\n    r2 0x00000001      r6 0x001026dc   r10 0x00000000    lr 0x00105cf1\r\n    r3 0x001314d0      r7 0x001026e0   r11 0x00000000    pc 0x00105790\r\n   Status of TA 5b9e0e40-2636-11e1-ad9e-0002a5d5c51b (0xe073b70) (active)\r\n    arch: arm  load address: 0x103000  ctx-idr: 1\r\n    stack: 0x100000 10240\r\n    region 0: va 0x100000 pa 0xe21e000 size 0x3000\r\n    region 1: va 0x103000 pa 0xe100000 size 0x2e000\r\n    region 2: va 0x131000 pa 0xe12e000 size 0xa000\r\n    region 3: va 0x13b000 pa 0xe138000 size 0xe6000\r\n    region 4: va 0 pa 0 size 0\r\n    region 5: va 0 pa 0 size 0\r\n    region 6: va 0 pa 0 size 0\r\n    region 7: va 0 pa 0 size 0\r\n>> User TA data-abort at address 0x1314d0 const_val+4 .rodata+4452 (write permission fault)\r\n   Call stack:\r\n    0x00105790 ta_entry_bad_mem_access at optee_test/ta/os_test/os_test.c:917\r\n    0x00105cf1 TA_InvokeCommandEntryPoint at optee_test/ta/os_test/ta_entry.c:101\r\n    0x00121e33 entry_invoke_command at optee_os/lib/libutee/arch/arm/user_ta_entry.c:207\r\n    0x00121e8f __utee_entry at optee_os/lib/libutee/arch/arm/user_ta_entry.c:235\r\n\r\nThe test TA does the following:\r\n\r\n  const int const_val[3] = { 1, };\r\n  /* ... */\r\n  ((int *)const_val)[1] = 2;\r\n\r\nSuggested-by: Zeng Tao <prime.zeng@hisilicon.com>\r\nSigned-off-by: Jerome Forissier <jerome.forissier@linaro.org>\r\n```","created_at":"2017-08-24T16:56:54Z","updated_at":"2017-08-29T12:09:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71c07a699e9121d290cddc4caf7461d08d5e0de5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767/commits","review_comments_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767/comments","review_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/1767/comments","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/38e47d7e2899845dd01d08ae40840459e3903d94","head":{"label":"jforissier:symbolize-abort-addr","ref":"symbolize-abort-addr","sha":"38e47d7e2899845dd01d08ae40840459e3903d94","user":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars2.githubusercontent.com/u/8288195?v=4","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"repo":{"id":22514248,"name":"optee_os","full_name":"jforissier/optee_os","owner":{"login":"jforissier","id":8288195,"avatar_url":"https://avatars2.githubusercontent.com/u/8288195?v=4","gravatar_id":"","url":"https://api.github.com/users/jforissier","html_url":"https://github.com/jforissier","followers_url":"https://api.github.com/users/jforissier/followers","following_url":"https://api.github.com/users/jforissier/following{/other_user}","gists_url":"https://api.github.com/users/jforissier/gists{/gist_id}","starred_url":"https://api.github.com/users/jforissier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jforissier/subscriptions","organizations_url":"https://api.github.com/users/jforissier/orgs","repos_url":"https://api.github.com/users/jforissier/repos","events_url":"https://api.github.com/users/jforissier/events{/privacy}","received_events_url":"https://api.github.com/users/jforissier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jforissier/optee_os","description":"Trusted side of the TEE","fork":true,"url":"https://api.github.com/repos/jforissier/optee_os","forks_url":"https://api.github.com/repos/jforissier/optee_os/forks","keys_url":"https://api.github.com/repos/jforissier/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jforissier/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jforissier/optee_os/teams","hooks_url":"https://api.github.com/repos/jforissier/optee_os/hooks","issue_events_url":"https://api.github.com/repos/jforissier/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/jforissier/optee_os/events","assignees_url":"https://api.github.com/repos/jforissier/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/jforissier/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/jforissier/optee_os/tags","blobs_url":"https://api.github.com/repos/jforissier/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jforissier/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jforissier/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/jforissier/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jforissier/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/jforissier/optee_os/languages","stargazers_url":"https://api.github.com/repos/jforissier/optee_os/stargazers","contributors_url":"https://api.github.com/repos/jforissier/optee_os/contributors","subscribers_url":"https://api.github.com/repos/jforissier/optee_os/subscribers","subscription_url":"https://api.github.com/repos/jforissier/optee_os/subscription","commits_url":"https://api.github.com/repos/jforissier/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/jforissier/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/jforissier/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/jforissier/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/jforissier/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/jforissier/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jforissier/optee_os/merges","archive_url":"https://api.github.com/repos/jforissier/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jforissier/optee_os/downloads","issues_url":"https://api.github.com/repos/jforissier/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/jforissier/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/jforissier/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/jforissier/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jforissier/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/jforissier/optee_os/releases{/id}","deployments_url":"https://api.github.com/repos/jforissier/optee_os/deployments","created_at":"2014-08-01T14:48:31Z","updated_at":"2016-03-11T08:17:47Z","pushed_at":"2017-08-25T16:43:33Z","git_url":"git://github.com/jforissier/optee_os.git","ssh_url":"git@github.com:jforissier/optee_os.git","clone_url":"https://github.com/jforissier/optee_os.git","svn_url":"https://github.com/jforissier/optee_os","homepage":null,"size":11816,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"OP-TEE:master","ref":"master","sha":"2fcf4eaaef0045916bbd38fe5867c0318d253db7","user":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars1.githubusercontent.com/u/7488961?v=4","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"repo":{"id":20193261,"name":"optee_os","full_name":"OP-TEE/optee_os","owner":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars1.githubusercontent.com/u/7488961?v=4","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OP-TEE/optee_os","description":"Trusted side of the TEE","fork":false,"url":"https://api.github.com/repos/OP-TEE/optee_os","forks_url":"https://api.github.com/repos/OP-TEE/optee_os/forks","keys_url":"https://api.github.com/repos/OP-TEE/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OP-TEE/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OP-TEE/optee_os/teams","hooks_url":"https://api.github.com/repos/OP-TEE/optee_os/hooks","issue_events_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/OP-TEE/optee_os/events","assignees_url":"https://api.github.com/repos/OP-TEE/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/OP-TEE/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/OP-TEE/optee_os/tags","blobs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OP-TEE/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/OP-TEE/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/OP-TEE/optee_os/languages","stargazers_url":"https://api.github.com/repos/OP-TEE/optee_os/stargazers","contributors_url":"https://api.github.com/repos/OP-TEE/optee_os/contributors","subscribers_url":"https://api.github.com/repos/OP-TEE/optee_os/subscribers","subscription_url":"https://api.github.com/repos/OP-TEE/optee_os/subscription","commits_url":"https://api.github.com/repos/OP-TEE/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/OP-TEE/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/OP-TEE/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/OP-TEE/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OP-TEE/optee_os/merges","archive_url":"https://api.github.com/repos/OP-TEE/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OP-TEE/optee_os/downloads","issues_url":"https://api.github.com/repos/OP-TEE/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/OP-TEE/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/OP-TEE/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OP-TEE/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/OP-TEE/optee_os/releases{/id}","deployments_url":"https://api.github.com/repos/OP-TEE/optee_os/deployments","created_at":"2014-05-26T17:18:57Z","updated_at":"2017-08-29T02:28:03Z","pushed_at":"2017-08-29T12:04:34Z","git_url":"git://github.com/OP-TEE/optee_os.git","ssh_url":"git@github.com:OP-TEE/optee_os.git","clone_url":"https://github.com/OP-TEE/optee_os.git","svn_url":"https://github.com/OP-TEE/optee_os","homepage":null,"size":11425,"stargazers_count":279,"watchers_count":279,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":250,"mirror_url":null,"open_issues_count":134,"forks":250,"open_issues":134,"watchers":279,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/1767"},"issue":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/1767"},"comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/1767/comments"},"review_comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767/comments"},"review_comment":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/1767/commits"},"statuses":{"href":"https://api.github.com/repos/OP-TEE/optee_os/statuses/38e47d7e2899845dd01d08ae40840459e3903d94"}}}}
{"actor":{"display_login":"jbech-linaro"}}