From 1b6aa10a6b489445ba37ef6a4633dd2b84cbb530 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 22 May 2019 08:49:31 -0700 Subject: 5216 --- html/subx/apps/handle.subx.html | 329 ++++++++++++++++++++-------------------- 1 file changed, 165 insertions(+), 164 deletions(-) (limited to 'html') diff --git a/html/subx/apps/handle.subx.html b/html/subx/apps/handle.subx.html index 072cda93..59cafb27 100644 --- a/html/subx/apps/handle.subx.html +++ b/html/subx/apps/handle.subx.html @@ -119,13 +119,13 @@ if ('onhashchange' in window) { 58 $new:continue: 59 # otherwise: 60 # ECX = *Next-alloc-id - 61 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 1/r32/ECX Next-alloc-id/disp32 # copy *Next-alloc-id to ECX + 61 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 1/r32/ECX Next-alloc-id/disp32 # copy *Next-alloc-id to ECX 62 # *EAX = *Next-alloc-id/ECX 63 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . . # copy ECX to *EAX 64 # out->alloc_id = *Next-alloc-id 65 89/copy 0/mod/indirect 2/rm32/EDX . . . 1/r32/ECX . . # copy ECX to *EDX 66 # increment *Next-alloc-id - 67 ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # increment *Next-alloc-id + 67 ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # increment *Next-alloc-id 68 $new:end: 69 # . restore registers 70 5a/pop-to-EDX @@ -153,7 +153,7 @@ if ('onhashchange' in window) { 92 # . . discard args 93 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP 94 # *Next-alloc-id = 0x34 - 95 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32 # copy to *Next-alloc-id + 95 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32 # copy to *Next-alloc-id 96 # var handle/ECX = {0, 0} 97 68/push 0/imm32/address 98 68/push 0/imm32/alloc-id @@ -190,14 +190,14 @@ if ('onhashchange' in window) { 129 # . . push args 130 68/push "F - test-new: next alloc id"/imm32 131 68/push 0x35/imm32 -132 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # copy to *Next-alloc-id +132 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # copy to *Next-alloc-id 133 # . . call 134 e8/call check-ints-equal/disp32 135 # . . discard args 136 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP 137 # clean up 138 # . *Next-alloc-id = 1 -139 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id +139 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id 140 # . epilog 141 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 142 5d/pop-to-EBP @@ -208,7 +208,7 @@ if ('onhashchange' in window) { 147 55/push-EBP 148 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 149 # . *Next-alloc-id = 0x34 -150 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32 # copy to *Next-alloc-id +150 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32 # copy to *Next-alloc-id 151 # define an allocation-descriptor with no space left 152 # . var ad/EAX : (address allocation-descriptor) = {0x10, 0x10} 153 68/push 0x10/imm32/limit @@ -252,14 +252,14 @@ if ('onhashchange' in window) { 191 # . . push args 192 68/push "F - test-new-failure: next alloc id"/imm32 193 68/push 0x34/imm32 -194 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # copy to *Next-alloc-id +194 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 # copy to *Next-alloc-id 195 # . . call 196 e8/call check-ints-equal/disp32 197 # . . discard args 198 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP 199 # clean up 200 # . *Next-alloc-id = 1 -201 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id +201 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id 202 # . epilog 203 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 204 5d/pop-to-EBP @@ -279,7 +279,7 @@ if ('onhashchange' in window) { 218 8b/copy 0/mod/indirect 0/rm32/EAX . . . . . . # copy *EAX to EAX 219 # if (EAX != *ESP) abort 220 39/compare 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 0/r32/EAX . . # compare *ESP and EAX -221 75/jump-if-not-equal $lookup:fail/disp8 +221 75/jump-if-not-equal $lookup:abort/disp8 222 # return ESP+4 223 58/pop-to-EAX 224 05/add-to-EAX 4/imm32 @@ -288,161 +288,162 @@ if ('onhashchange' in window) { 227 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 228 5d/pop-to-EBP 229 c3/return -230 $lookup:fail: -231 # . _write(2/stderr, msg) -232 # . . push args -233 68/push "lookup failed"/imm32 -234 68/push 2/imm32/stderr -235 # . . call -236 e8/call _write/disp32 -237 # . . discard args -238 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -239 # . syscall(exit, 1) -240 bb/copy-to-EBX 1/imm32/exit-status -241 b8/copy-to-EAX 1/imm32/exit -242 cd/syscall 0x80/imm8 -243 -244 test-lookup-success: -245 # . prolog -246 55/push-EBP -247 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -248 # . save registers -249 # var heap/EBX : (address allocation-descriptor) = {0, 0} -250 68/push 0/imm32/limit -251 68/push 0/imm32/curr -252 89/copy 3/mod/direct 3/rm32/EBX . . . 4/r32/ESP . . # copy ESP to EBX -253 # heap = new-segment(512) -254 # . . push args -255 53/push-EBX -256 68/push 0x200/imm32 -257 # . . call -258 e8/call new-segment/disp32 -259 # . . discard args -260 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -261 # var handle/ECX = {0, 0} -262 68/push 0/imm32/address -263 68/push 0/imm32/alloc-id -264 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX -265 # var old_top/EDX = heap->curr -266 8b/copy 0/mod/indirect 3/rm32/EBX . . . 2/r32/EDX . . # copy *EBX to EDX -267 # new(heap, 2, handle) -268 # . . push args -269 51/push-ECX -270 68/push 2/imm32/size -271 53/push-EBX -272 # . . call -273 e8/call new/disp32 -274 # . . discard args -275 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -276 # EAX = lookup(handle) -277 # . . push args -278 51/push-ECX -279 # . . call -280 e8/call lookup/disp32 -281 # . . discard args -282 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -283 # EAX contains old top of heap, except skipping the alloc id in the payload -284 # . check-ints-equal(EAX, old_top+4, msg) -285 # . . push args -286 68/push "F - test-lookup-success"/imm32 -287 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 4/imm32 # add to EDX -288 52/push-EDX -289 50/push-EAX -290 # . . call -291 e8/call check-ints-equal/disp32 -292 # . . discard args -293 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -294 # clean up -295 # . *Next-alloc-id = 1 -296 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id -297 # . restore registers -298 5a/pop-to-EDX -299 59/pop-to-ECX -300 # . epilog -301 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -302 5d/pop-to-EBP -303 c3/return -304 -305 test-lookup-failure: -306 # . prolog -307 55/push-EBP -308 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -309 # var heap/ESI : (address allocation-descriptor) = {0, 0} -310 68/push 0/imm32/limit -311 68/push 0/imm32/curr -312 89/copy 3/mod/direct 6/rm32/ESI . . . 4/r32/ESP . . # copy ESP to ESI -313 # heap = new-segment(512) -314 # . . push args -315 56/push-ESI -316 68/push 0x200/imm32 -317 # . . call -318 e8/call new-segment/disp32 -319 # . . discard args -320 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -321 # var h1/ECX = {0, 0} -322 68/push 0/imm32/address -323 68/push 0/imm32/alloc-id -324 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX -325 # var old_top/EBX = heap->curr -326 8b/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . . # copy *ESI to EBX -327 # first allocation, to h1 -328 # . new(heap, 2, h1) -329 # . . push args -330 51/push-ECX -331 68/push 2/imm32/size -332 56/push-ESI -333 # . . call -334 e8/call new/disp32 -335 # . . discard args -336 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -337 # reset heap->curr to mimic reclamation -338 89/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . . # copy EBX to *ESI -339 # second allocation that returns the same address as the first -340 # var h2/EDX = {0, 0} -341 68/push 0/imm32/address -342 68/push 0/imm32/alloc-id -343 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX -344 # . new(heap, 2, h2) -345 # . . push args -346 52/push-EDX -347 68/push 2/imm32/size -348 56/push-ESI -349 # . . call -350 e8/call new/disp32 -351 # . . discard args -352 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -353 # check-ints-equal(h1->address, h2->address, msg) -354 # . . push args -355 68/push "F - test-lookup-failure"/imm32 -356 ff 6/subop/push 1/mod/*+disp8 2/rm32/ECX . . . . 4/disp8 . # push *(EDX+4) -357 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) -358 # . . call -359 e8/call check-ints-equal/disp32 -360 # . . discard args -361 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -362 # lookup(h1) should crash -363 # . . push args -364 51/push-ECX -365 # . . call -366 e8/call lookup/disp32 -367 # should never get past this point -368 # . . discard args -369 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -370 # clean up -371 # . *Next-alloc-id = 1 -372 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id -373 # . epilog -374 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -375 5d/pop-to-EBP -376 c3/return -377 -378 == data -379 -380 # Monotonically increasing counter for calls to 'new' -381 Next-alloc-id: -382 1/imm32 -383 -384 # . . vim:nowrap:textwidth=0 +230 +231 $lookup:abort: +232 # . _write(2/stderr, msg) +233 # . . push args +234 68/push "lookup failed"/imm32 +235 68/push 2/imm32/stderr +236 # . . call +237 e8/call _write/disp32 +238 # . . discard args +239 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +240 # . syscall(exit, 1) +241 bb/copy-to-EBX 1/imm32/exit-status +242 b8/copy-to-EAX 1/imm32/exit +243 cd/syscall 0x80/imm8 +244 +245 test-lookup-success: +246 # . prolog +247 55/push-EBP +248 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +249 # . save registers +250 # var heap/EBX : (address allocation-descriptor) = {0, 0} +251 68/push 0/imm32/limit +252 68/push 0/imm32/curr +253 89/copy 3/mod/direct 3/rm32/EBX . . . 4/r32/ESP . . # copy ESP to EBX +254 # heap = new-segment(512) +255 # . . push args +256 53/push-EBX +257 68/push 0x200/imm32 +258 # . . call +259 e8/call new-segment/disp32 +260 # . . discard args +261 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +262 # var handle/ECX = {0, 0} +263 68/push 0/imm32/address +264 68/push 0/imm32/alloc-id +265 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX +266 # var old_top/EDX = heap->curr +267 8b/copy 0/mod/indirect 3/rm32/EBX . . . 2/r32/EDX . . # copy *EBX to EDX +268 # new(heap, 2, handle) +269 # . . push args +270 51/push-ECX +271 68/push 2/imm32/size +272 53/push-EBX +273 # . . call +274 e8/call new/disp32 +275 # . . discard args +276 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +277 # EAX = lookup(handle) +278 # . . push args +279 51/push-ECX +280 # . . call +281 e8/call lookup/disp32 +282 # . . discard args +283 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +284 # EAX contains old top of heap, except skipping the alloc id in the payload +285 # . check-ints-equal(EAX, old_top+4, msg) +286 # . . push args +287 68/push "F - test-lookup-success"/imm32 +288 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 4/imm32 # add to EDX +289 52/push-EDX +290 50/push-EAX +291 # . . call +292 e8/call check-ints-equal/disp32 +293 # . . discard args +294 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +295 # clean up +296 # . *Next-alloc-id = 1 +297 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id +298 # . restore registers +299 5a/pop-to-EDX +300 59/pop-to-ECX +301 # . epilog +302 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +303 5d/pop-to-EBP +304 c3/return +305 +306 test-lookup-failure: +307 # . prolog +308 55/push-EBP +309 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +310 # var heap/ESI : (address allocation-descriptor) = {0, 0} +311 68/push 0/imm32/limit +312 68/push 0/imm32/curr +313 89/copy 3/mod/direct 6/rm32/ESI . . . 4/r32/ESP . . # copy ESP to ESI +314 # heap = new-segment(512) +315 # . . push args +316 56/push-ESI +317 68/push 0x200/imm32 +318 # . . call +319 e8/call new-segment/disp32 +320 # . . discard args +321 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +322 # var h1/ECX = {0, 0} +323 68/push 0/imm32/address +324 68/push 0/imm32/alloc-id +325 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX +326 # var old_top/EBX = heap->curr +327 8b/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . . # copy *ESI to EBX +328 # first allocation, to h1 +329 # . new(heap, 2, h1) +330 # . . push args +331 51/push-ECX +332 68/push 2/imm32/size +333 56/push-ESI +334 # . . call +335 e8/call new/disp32 +336 # . . discard args +337 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +338 # reset heap->curr to mimic reclamation +339 89/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . . # copy EBX to *ESI +340 # second allocation that returns the same address as the first +341 # var h2/EDX = {0, 0} +342 68/push 0/imm32/address +343 68/push 0/imm32/alloc-id +344 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . . # copy ESP to EDX +345 # . new(heap, 2, h2) +346 # . . push args +347 52/push-EDX +348 68/push 2/imm32/size +349 56/push-ESI +350 # . . call +351 e8/call new/disp32 +352 # . . discard args +353 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +354 # check-ints-equal(h1->address, h2->address, msg) +355 # . . push args +356 68/push "F - test-lookup-failure"/imm32 +357 ff 6/subop/push 1/mod/*+disp8 2/rm32/ECX . . . . 4/disp8 . # push *(EDX+4) +358 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) +359 # . . call +360 e8/call check-ints-equal/disp32 +361 # . . discard args +362 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +363 # lookup(h1) should crash +364 # . . push args +365 51/push-ECX +366 # . . call +367 e8/call lookup/disp32 +368 # should never get past this point +369 # . . discard args +370 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +371 # clean up +372 # . *Next-alloc-id = 1 +373 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32 # copy to *Next-alloc-id +374 # . epilog +375 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +376 5d/pop-to-EBP +377 c3/return +378 +379 == data +380 +381 # Monotonically increasing counter for calls to 'new' +382 Next-alloc-id: +383 1/imm32 +384 +385 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0