41-503: [REDACTED] Look up alter in Wiktionary, the free dictionary. Alter may refer to: Computing and technology [ edit ] ALTER , a command in older implementations of COBOL Alter (SQL) , a command in a data definition language within SQL Music [ edit ] Alter (album) , 2002 album by Floater Alter ,
82-597: A structured , or even object oriented , approach to self-modifying code, where code is created for individual quajects , like filehandles. Generating code for specific tasks allows the Synthesis kernel to (as a JIT interpreter might) apply a number of optimizations such as constant folding or common subexpression elimination . The Synthesis kernel was very fast, but was written entirely in assembly. The resulting lack of portability has prevented Massalin's optimization ideas from being adopted by any production kernel. However,
123-643: A "second self" Archbishop Alter High School , a Roman Catholic high school in Kettering, Ohio See also [ edit ] Altar (disambiguation) Topics referred to by the same term [REDACTED] This disambiguation page lists articles associated with the title Alter . If an internal link led you here, you may wish to change the link to point directly to the intended article. Retrieved from " https://en.wikipedia.org/w/index.php?title=Alter&oldid=1252416548 " Category : Disambiguation pages Hidden categories: Short description
164-440: A 2006 remix album by Swiss band Knut "Alter", a song from the 1994 album Glow , by Raven TV and media [ edit ] ALTER (streaming service) a channel dedicated to horror, run by Gunpowder & Sky Alter Channel , a Greek TV channel Other uses [ edit ] Alter (name) , people named Alter Alter (automobile) Alter (crater) , a lunar crater Alter ego , or "alter" in popular usage,
205-494: A command SOMENAME to be performed: SHOWMENU exits after rewriting the file MENU.BAT to contain Because the DOS command interpreter does not compile a script file and then execute it, nor does it read the entire file into memory before starting execution, nor yet rely on the content of a record buffer, when SHOWMENU exits, the command interpreter finds a new command to execute (it is to invoke
246-424: A general situation, there may be an option of associating weights with the data, so each x i is associated with a w i and rather than test for the presence of weights at every index value, there could be two versions of the calculation, one for use with weights and one not, with one test at the start. Now consider a further option, that each value may have associated with it a Boolean to signify whether that value
287-531: A lesser extent, the DR-DOS kernel also optimizes speed-critical sections of itself at loadtime depending on the underlying processor generation. Regardless, at a meta-level , programs can still modify their own behavior by changing data stored elsewhere (see metaprogramming ) or via use of polymorphism . The Synthesis kernel presented in Alexia Massalin 's Ph.D. thesis is a tiny Unix kernel that takes
328-434: A matter of rewriting the loop like this: Note that two-state replacement of the opcode can be easily written as 'xor var at address with the value "opcodeOf(Inc) xor opcodeOf(dec)"'. Choosing this solution must depend on the value of N and the frequency of state changing. Suppose a set of statistics such as average, extrema, location of extrema, standard deviation, etc. are to be calculated for some large data set. In
369-494: A piece of running code is also used in certain attacks, such as buffer overflows . Traditional machine learning systems have a fixed, pre-programmed learning algorithm to adjust their parameters . However, since the 1980s Jürgen Schmidhuber has published several self-modifying systems with the ability to change their own learning algorithm. They avoid the danger of catastrophic self-rewrites by making sure that self-modifications will survive only if they are useful according to
410-490: A procedure. With interpreted languages, the "machine code" is the source text and may be susceptible to editing on-the-fly: in SNOBOL the source statements being executed are elements of a text array. Other languages, such as Perl and Python , allow programs to create new code at run-time and execute it using an eval function, but do not allow existing code to be mutated. The illusion of modification (even though no machine code
451-404: A program from making any page of memory both writable and executable. Some systems prevent a writable page from ever being changed to be executable, even if write permission is removed. Other systems provide a ' back door ' of sorts, allowing multiple mappings of a page of memory to have different permissions. A relatively portable way to bypass W^X is to create a file with all permissions, then map
SECTION 10
#1732845222297492-461: A sequence equivalent to the ones that a standard compiler may generate as the object code . With modern processors, there can be unintended side effects on the CPU cache that must be considered. The method was frequently used for testing 'first time' conditions, as in this suitably commented IBM/360 assembler example. It uses instruction overlay to reduce the instruction path length by (N×1)−1 where N
533-458: A system be signed. Modified code must be stored separately from its original form, conflicting with memory management solutions that normally discard the code in RAM and reload it from the executable file as needed. On modern processors with an instruction pipeline , code that modifies itself frequently may run more slowly, if it modifies instructions that the processor has already read from memory into
574-454: A user-given fitness , error or reward function. The Linux kernel notably makes wide use of self-modifying code; it does so to be able to distribute a single binary image for each major architecture (e.g. IA-32 , x86-64 , 32-bit ARM , ARM64 ...) while adapting the kernel code in memory during boot depending on the specific CPU model detected, e.g. to be able to take advantage of new CPU instructions or to work around hardware bugs. To
615-524: A value, such as a disk address, is read into an area referenced by a channel program, where it is used by a later channel command to access the disk. The IBM SSEC , demonstrated in January 1948, had the ability to modify its instructions or otherwise treat them exactly like data. However, the capability was rarely used in practice. In the early days of computers, self-modifying code was often used to reduce use of limited memory, or improve performance, or both. It
656-514: Is an example in Zilog Z80 assembly language. The code increments register "B" in range [0,5]. The "CP" compare instruction is modified on each loop. Self-modifying code is sometimes used to overcome limitations in a machine's instruction set. For example, in the Intel 8080 instruction set, one cannot input a byte from an input port that is specified in a register. The input port is statically encoded in
697-428: Is clear that the names of functions to be called are placeholders for functions to be identified later. Self-modifying code can be rewritten as code that tests a flag and branches to alternative sequences based on the outcome of the test, but self-modifying code typically runs faster. Self-modifying code conflicts with authentication of the code and may require exceptions to policies requiring that all code running on
738-459: Is different from Wikidata All article disambiguation pages All disambiguation pages Self-modifying code#High-level languages In computer science , self-modifying code ( SMC or SMoC ) is code that alters its own instructions while it is executing – usually to reduce the instruction path length and improve performance or simply to reduce otherwise repetitively similar code , thus simplifying maintenance . The term
779-455: Is modified during execution. Some batch programming techniques involve the use of self-modifying code. Clipper and SPITBOL also provide facilities for explicit self-modification. The Algol compiler on B6700 systems offered an interface to the operating system whereby executing code could pass a text string or a named disc file to the Algol compiler and was then able to invoke the new version of
820-425: Is not altered. Self-modification can be accomplished in a variety of ways depending upon the programming language and its support for pointers and/or access to dynamic compiler or interpreter 'engines': Self-modifying code is quite straightforward to implement when using assembly language . Instructions can be dynamically created in memory (or else overlaid over existing code in non-protected program storage), in
861-426: Is really being overwritten) is achieved by modifying function pointers, as in this JavaScript example: Lisp macros also allow runtime code generation without parsing a string containing program code. The Push programming language is a genetic programming system that is explicitly designed for creating self-modifying programs. While not a high level language, it is not as low level as assembly language. Prior to
SECTION 20
#1732845222297902-459: Is required, because the DOS command interpreter recalls the byte position of the next command when it is to start the next command, thus the re-written file must maintain alignment for the next command start point to indeed be the start of the next command. Aside from the convenience of a menu system (and possible auxiliary features), this scheme means that the SHOWMENU.EXE system is not in memory when
943-408: Is the number of records on the file (−1 being the overhead to perform the overlay). Alternative code might involve testing a "flag" each time through. The unconditional branch is slightly faster than a compare instruction, as well as reducing the overall path length. In later operating systems for programs residing in protected storage this technique could not be used and so changing the pointer to
984-423: Is to be skipped or not. This could be handled by producing four batches of code, one for each permutation and code bloat results. Alternatively, the weight and the skip arrays could be merged into a temporary array (with zero weights for values to be skipped), at the cost of processing and still there is bloat. However, with code modification, to the template for calculating the statistics could be added as appropriate
1025-462: Is usually only applied to code where the self-modification is intentional, not in situations where code accidentally modifies itself due to an error such as a buffer overflow . Self-modifying code can involve overwriting existing instructions or generating new code at run time and transferring control to that code. Self-modification can be used as an alternative to the method of "flag setting" and conditional program branching, used primarily to reduce
1066-471: The floppy disk drive access instruction int 0x13 would not appear in the executable program's image but it would be written into the executable's memory image after the program started executing. Self-modifying code is also sometimes used by programs that do not want to reveal their presence, such as computer viruses and some shellcodes . Viruses and shellcodes that use self-modifying code mostly do this in combination with polymorphic code . Modifying
1107-462: The subroutine would be used instead. The pointer would reside in dynamic storage and could be altered at will after the first pass to bypass the OPEN (having to load a pointer first instead of a direct branch & link to the subroutine would add N instructions to the path length – but there would be a corresponding reduction of N for the unconditional branch that would no longer be required). Below
1148-414: The advent of multiple windows, command-line systems might offer a menu system involving the modification of a running command script. Suppose a DOS script (or "batch") file MENU.BAT contains the following: Upon initiation of MENU.BAT from the command line, SHOWMENU presents an on-screen menu, with possible help information, example usages and so forth. Eventually the user makes a selection that requires
1189-399: The cache synchronization must be explicitly performed by the modifying code (flush data cache and invalidate instruction cache for the modified memory area). In some cases short sections of self-modifying code execute more slowly on modern processors. This is because a modern processor will usually try to keep blocks of code in its cache memory. Each time the program rewrites a part of itself,
1230-556: The code for skipping unwanted values, and for applying weights. There would be no repeated testing of the options and the data array would be accessed once, as also would the weight and skip arrays, if involved. Self-modifying code is more complex to analyze than standard code and can therefore be used as a protection against reverse engineering and software cracking . Self-modifying code was used to hide copy protection instructions in 1980s disk-based programs for systems such as IBM PC compatibles and Apple II . For example, on an IBM PC,
1271-481: The existing ones (for example: altering a compare and branch to an unconditional branch or alternatively a ' NOP '). In the IBM System/360 architecture , and its successors up to z/Architecture , an EXECUTE (EX) instruction logically overlays the second byte of its target instruction with the low-order 8 bits of register 1. This provides the effect of self-modification although the actual instruction in storage
Alter - Misplaced Pages Continue
1312-426: The file into memory twice. On Linux, one may use an undocumented SysV shared memory flag to get executable shared memory without needing to create a file. Self-modifying code is harder to read and maintain because the instructions in the source program listing are not necessarily the instructions that will be executed. Self-modification that consists of substitution of function pointers might not be as cryptic, if it
1353-509: The instruction itself, as the second byte of a two byte instruction. Using self-modifying code, it is possible to store a register's contents into the second byte of the instruction, then execute the modified instruction in order to achieve the desired effect. Some compiled languages explicitly permit self-modifying code. For example, the ALTER verb in COBOL may be implemented as a branch instruction that
1394-542: The modification will occur rarely, such as in the case of a state switching inside an inner loop. Most modern processors load the machine code before they execute it, which means that if an instruction that is too near the instruction pointer is modified, the processor will not notice, but instead execute the code as it was before it was modified. See prefetch input queue (PIQ). PC processors must handle self-modifying code correctly for backwards compatibility reasons but they are far from efficient at doing so. Because of
1435-403: The number of times a condition needs to be tested. The method is frequently used for conditionally invoking test/debugging code without requiring additional computational overhead for every input/output cycle. The modifications may be performed: In either case, the modifications may be performed directly to the machine code instructions themselves, by overlaying new instructions over
1476-401: The rewritten part must be loaded into the cache again, which results in a slight delay, if the modified codelet shares the same cache line with the modifying code, as is the case when the modified memory address is located within a few bytes to the one of the modifying code. The cache invalidation issue on modern processors usually means that self-modifying code would still be faster only when
1517-406: The script file SOMENAME , in a directory location and via a protocol known to SHOWMENU), and after that command completes, it goes back to the start of the script file and reactivates SHOWMENU ready for the next selection. Should the menu choice be to quit, the file would be rewritten back to its original state. Although this starting state has no use for the label, it, or an equivalent amount of text
1558-450: The security implications of self-modifying code, all of the major operating systems are careful to remove such vulnerabilities as they become known. The concern is typically not that programs will intentionally modify themselves, but that they could be maliciously changed by an exploit . One mechanism for preventing malicious code modification is an operating system feature called W^X (for "write xor execute"). This mechanism prohibits
1599-409: The selected command is activated, a significant advantage when memory is limited. Control table interpreters can be considered to be, in one sense, 'self-modified' by data values extracted from the table entries (rather than specifically hand coded in conditional statements of the form "IF inputx = 'yyy'"). Some IBM access methods traditionally used self-modifying channel programs , where
1640-535: The structure of the techniques suggests that they could be captured by a higher level language , albeit one more complex than existing mid-level languages. Such a language and compiler could allow development of faster operating systems and applications. Paul Haeberli and Bruce Karsh have objected to the "marginalization" of self-modifying code, and optimization in general, in favor of reduced development costs. On architectures without coupled data and instruction cache (for example, some SPARC , ARM, and MIPS cores)
1681-545: Was also sometimes used to implement subroutine calls and returns when the instruction set only provided simple branching or skipping instructions to vary the control flow . This use is still relevant in certain ultra- RISC architectures, at least theoretically; see for example one-instruction set computer . Donald Knuth 's MIX architecture also used self-modifying code to implement subroutine calls. Self-modifying code can be used for various purposes: Pseudocode example: Self-modifying code, in this case, would simply be