{"action":"created","issue":{"url":"https://api.github.com/repos/angr/angr/issues/262","repository_url":"https://api.github.com/repos/angr/angr","labels_url":"https://api.github.com/repos/angr/angr/issues/262/labels{/name}","comments_url":"https://api.github.com/repos/angr/angr/issues/262/comments","events_url":"https://api.github.com/repos/angr/angr/issues/262/events","html_url":"https://github.com/angr/angr/issues/262","id":188434452,"number":262,"title":"load hand written asm program failed","user":{"login":"tovain10071991","id":3599157,"avatar_url":"https://avatars.githubusercontent.com/u/3599157?v=3","gravatar_id":"","url":"https://api.github.com/users/tovain10071991","html_url":"https://github.com/tovain10071991","followers_url":"https://api.github.com/users/tovain10071991/followers","following_url":"https://api.github.com/users/tovain10071991/following{/other_user}","gists_url":"https://api.github.com/users/tovain10071991/gists{/gist_id}","starred_url":"https://api.github.com/users/tovain10071991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tovain10071991/subscriptions","organizations_url":"https://api.github.com/users/tovain10071991/orgs","repos_url":"https://api.github.com/users/tovain10071991/repos","events_url":"https://api.github.com/users/tovain10071991/events{/privacy}","received_events_url":"https://api.github.com/users/tovain10071991/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-10T06:59:31Z","updated_at":"2016-11-12T08:34:05Z","closed_at":null,"body":"I code a asm program as follow:\r\n```\r\n# hello.s\r\n.section .text\r\n.global _start\r\n_start:\r\n  movq $0, %rdi\r\n  movq $60, %rax # SYS_exit\r\n  syscall\r\n```\r\n\r\nif I execute the command；\r\n```\r\n$ as -o hello.o hello.s\r\n$ ld --dynamic-linker=/lib64/ld-linux-x86-64.so.2 hello.o -lc -o hello\r\n```\r\nwhere link libc ( it is unnecessary but it is not wrong when not linking libc)\r\nthen I construct Project with error:\r\n```\r\n>>> p = angr.Project(\"./hello\")\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python2.7/dist-packages/angr/project.py\", line 107, in __init__\r\n    self.loader = cle.Loader(self.filename, **load_options)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/loader.py\", line 94, in __init__\r\n    self._load_main_binary()\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/loader.py\", line 154, in _load_main_binary\r\n    is_main_bin=True)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/loader.py\", line 266, in load_object\r\n    loaded = backend(path, compatible_with=compatible_with, filetype=filetype, is_main_bin=is_main_bin, **options)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/backends/elf.py\", line 179, in __init__\r\n    self.__register_segments()\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/backends/elf.py\", line 319, in __register_segments\r\n    self.__register_dyn(seg_readelf)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/backends/elf.py\", line 361, in __register_dyn\r\n    self.deps = map(self.strtab.get_string, self.deps)\r\n  File \"/usr/local/lib/python2.7/dist-packages/elftools/elf/sections.py\", line 69, in get_string\r\n    s = parse_cstring_from_stream(self.stream, table_offset + offset)\r\n  File \"/usr/local/lib/python2.7/dist-packages/elftools/common/utils.py\", line 53, in parse_cstring_from_stream\r\n    chunk = stream.read(CHUNKSIZE)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/memory.py\", line 238, in read\r\n    out = self.read_bytes(self._pointer, nbytes)\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/memory.py\", line 116, in read_bytes\r\n    b.append(self.get_byte(i, orig=orig))\r\n  File \"/usr/local/lib/python2.7/dist-packages/cle/memory.py\", line 87, in get_byte\r\n    raise KeyError(k)\r\nKeyError: 4194808 # 0x4001f8\r\n```\r\n\r\nwhere the 0x4001f8 is end of executable LOAD program:\r\n```\r\nProgram Headers:\r\n  Type           Offset             VirtAddr           PhysAddr\r\n                 FileSiz            MemSiz              Flags  Align\r\n  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040\r\n                 0x0000000000000150 0x0000000000000150  R E    8\r\n  INTERP         0x0000000000000190 0x0000000000400190 0x0000000000400190\r\n                 0x000000000000001c 0x000000000000001c  R      1\r\n      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]\r\n  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000\r\n                 0x00000000000001f8 0x00000000000001f8  R E    200000\r\n  LOAD           0x0000000000000f30 0x0000000000600f30 0x0000000000600f30\r\n                 0x00000000000000d0 0x00000000000000d0  RW     200000\r\n  DYNAMIC        0x0000000000000f30 0x0000000000600f30 0x0000000000600f30\r\n                 0x00000000000000d0 0x00000000000000d0  RW     8\r\n  GNU_RELRO      0x0000000000000f30 0x0000000000600f30 0x0000000000600f30\r\n                 0x00000000000000d0 0x00000000000000d0  R      1\r\n```\r\n\r\nMy OS:\r\n```\r\n$ uname -a\r\nLinux user-PC 4.8.0-26-generic #28-Ubuntu SMP Tue Oct 18 14:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux\r\n```"},"comment":{"url":"https://api.github.com/repos/angr/angr/issues/comments/260109618","html_url":"https://github.com/angr/angr/issues/262#issuecomment-260109618","issue_url":"https://api.github.com/repos/angr/angr/issues/262","id":260109618,"user":{"login":"tovain10071991","id":3599157,"avatar_url":"https://avatars.githubusercontent.com/u/3599157?v=3","gravatar_id":"","url":"https://api.github.com/users/tovain10071991","html_url":"https://github.com/tovain10071991","followers_url":"https://api.github.com/users/tovain10071991/followers","following_url":"https://api.github.com/users/tovain10071991/following{/other_user}","gists_url":"https://api.github.com/users/tovain10071991/gists{/gist_id}","starred_url":"https://api.github.com/users/tovain10071991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tovain10071991/subscriptions","organizations_url":"https://api.github.com/users/tovain10071991/orgs","repos_url":"https://api.github.com/users/tovain10071991/repos","events_url":"https://api.github.com/users/tovain10071991/events{/privacy}","received_events_url":"https://api.github.com/users/tovain10071991/received_events","type":"User","site_admin":false},"created_at":"2016-11-12T08:34:05Z","updated_at":"2016-11-12T08:34:05Z","body":"I'm sorry because i make a mistake in what I say in previous commit: 0x4001f8 is after the end of LOAD program not end of .text section.\r\n\r\nThe assembly and the binary layout is above.\r\n\r\nThe data read in get_byte is contents from begin of binary to 0x4001f7. But CHUNKSIZE in parse_cstring_from_stream is fixedly 64.\r\n\r\nThank you for your help and explanation!"}}
{"actor":{"display_login":"tovain10071991"}}