{"id":19297228,"url":"https://github.com/xerub/ropc","last_synced_at":"2025-04-22T08:31:21.395Z","repository":{"id":96680381,"uuid":"43090438","full_name":"xerub/ropc","owner":"xerub","description":"meine kleine rop compiler, circa 2012","archived":false,"fork":false,"pushed_at":"2021-08-16T22:40:38.000Z","size":146,"stargazers_count":68,"open_issues_count":0,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-09T23:02:24.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xerub.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-24T20:08:33.000Z","updated_at":"2023-10-07T21:38:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"8bef43a8-daf0-404e-922d-584e810bf8fa","html_url":"https://github.com/xerub/ropc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerub%2Fropc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerub%2Fropc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerub%2Fropc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xerub%2Fropc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xerub","download_url":"https://codeload.github.com/xerub/ropc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250206163,"owners_count":21392200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:01:48.633Z","updated_at":"2025-04-22T08:31:21.389Z","avatar_url":"https://github.com/xerub.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"1. The input is a C-like preprocessed source, the output is a NASM-like strip.\n\tdg\t-\u003e define gadget, which must be slid by library slide\n\tdu\t-\u003e define local, which must be slid by strip slide\n\tdd\t-\u003e define data (%define dd -\u003e dq for 64bit)\n\n2. we implement lazy assignment.  that is, an assignment is not guaranteed\n    to generate code, it only guarantees that when first using the assigned\n    variable, it will have the desired value.  however, since we do not have\n    proper flow analysis, any assignment in a loop cannot be lazy. see 'const'\n\n3. immediate expressions involving local pointers cannot be simplified, unless\n    they can be reduced to: PTR + scalar.  that is because there is one single\n    final addition applied by the assembler, after full evaluation.\n\n4. strings are treated as implicit addresses.  therefore,\n\tb = \"a\" + 1\n    really means:\n\tstr = \"a\"\n\tb = \u0026str + 1\n    also, compound expressions are treated just like strings, with \"long\"\n    values instead of characters\n\n5. imports are implicit addresses.  to actually use external variables, do\n\t*optind = 0;\n\ta = *optind;\n\n6. sometimes, it is better to use multiple assignments for the same value\n\tfd = fd2 = open(...);\n\tread(fd, ...);\n\tclose(fd2);\n    instead of\n\tfd = open(...);\n\tread(fd, ...);\n\tclose(fd);\n\n7. this contrived load/store architecture stems from the assumptions that\n    some rop gadgets are hard -- or impossible -- to find.  for example,\n    it is hard to load r1 without r0\n\n8. jumping to labels in the past is tricky, because stack above us is\n    destroyed by calls in-between.  for the same reason, parameters\n    referencing things in the past are WRONG:\n\tlabel:\n\tx = 1;\n\tprintf(\"x=%x\\n\", x);\n\tif (modify(\u0026x)) goto label;\n    stack above modify is destroyed, so jumping back to label is problematic.\n    also, any use of *(\u0026x) is probably doomed.  therefore, we need to reserve\n    some stack space before any such calls. see '[[stack]]'\n\n====\n\nconst:\n    used for\n\tvar = immediate\n    to avoid generating\n\t*\u0026var = immediate\n    var is inlined and defined as immediate, when possible\n    useful inside loops\n\nvolatile:\n    used for\n\tx = var\n    to force generating\n\tx = *\u0026var\n    var is never inlined\n    needed when a variable is used before and after a function call\n\ntherefore\n    \"const volatile\" is perfectly ok :)\n    because the var will never be inlined, but will not generate code for assignment\n\n====\n\nextern function[[attr]];\na = function;\na();\t\twill not respect import attributes\n[[attr]]a();\twill respect call attributes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerub%2Fropc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxerub%2Fropc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxerub%2Fropc/lists"}