
There are two parts to the image labeled Stack. Part (a): There is a vertical block with multiple partitions and with both sides open-ended. The partitions labeled from top to bottom are 1. ampersand gadget C. 2. data. 3. ampersand gadget B. 4. data. 5. ampersand gadget A. There are backward arrows from ampersand gadget A to ampersand gadget B and from ampersand gadget B to ampersand gadget C. Some space is empty in the vertical block without partitions. Now, again partitions are labeled as 1. RETURN. 2. instruction 4. 3. instruction 3. 4. instruction 2. 5. instruction 1 and this is categorized as gadget C (part of function Z) with a forward arrow pointing to instruction 1. Again some space is empty in the vertical block without partitions. Now, again partitions are labeled as 1. RETURN. 2. instruction 3. 3. instruction 2. 4. instruction 1 and this is categorized as gadget B (part of function Y) with a forward arrow pointing to instruction 1. There is a vertical block with a backward arrow on the top line that starts from instruction 1 from the previous block to this block's RETURN. Now, again some space that is empty in the vertical block without partitions. Now, again partitions are labeled as 1. RETURN. 2. instruction 4. 3. instruction 3. 4. instruction 2. 5. Instruction 1 and this partition is categorized as gadget A (part of function X) with a forward arrow pointing to instruction 1. There is a vertical block with a backward arrow on the top line that starts from instruction 1 from the previous block to this block's RETURN. There is a dashed line vertical block starting from partition ampersand gadget A and ending at the last instruction 1 partition with a backward arrow at the bottom line. Part (b): There is a square block labeled Text Segment. Line 1: Example gadgets: Line 2: Gadget A: Line 3: -pop operand off the stack into register 1. Line 4: -if the value is negative, jump to the error handler. Line 5: -otherwise return. Line 6: Gadget B: Line 7: -pop operand off the stack into register 2. Line 7: -return. Line 8: Gadget C: Line 9: -multiply register 1 by 4. Line 10: -push register 1. Line 11: -add register 2 to the value on the top of the stack and store the result in register 2.
Back