~/ / posts / Compiler_interpreter

COMPILER & INTERPRETER

Programs written in high-level languages like C must be translated into machine-readable instructions before they can execute on a computer.

COMPILER & INTERPRETER

Programs written in high-level languages like C must be translated into machine-readable instructions before they can execute on a computer.

The GCC compiler driver performs this translation through a four-phase compilation system that progressively transforms source code (c code) into an executable binary file (machine code).

image.png

Preprocessing Phase:

C File —> clean C File

The preprocessor (cpp) modifies the original C source code by processing directives that begin with '#' (includes)

output: modified C program with a .i extension

Compiler phase:

clean C File —> Assembly language File

The compiler (cc1) translates the preprocessed .i file into assembly language, producing a .s file

assembly language: Assembly language serves as an intermediate representation that different high-level languages (C, Fortran, etc.) can compile to, providing a common ground. Each line in the assembly file represents a low-level machine instruction in textual form, such as movl or call instructions

output: producing a .s file in assembly language

Assembly Phase:

Assembly language File —> Binary File

The assembler (as) converts assembly language instructions from the .s file into actual machine code—binary instructions the processor can execute.

output : relocatable object file (.o extension) containing binary-encoded instructions.

Linker Phase:

Binary File + all other files (printf.o) —> executable

if we have printf function in our file the compiler create a separate precompiled object file called printf.o which must be merged with our hello.o program The linker (ld) handles this merging The result is an executable object file—or simply executable—called hello

ready to be loaded into memory and executed by the system


Compiler (in detail):

how the english text is converted into assembly code? heres how: there are these steps:

  1. Lexical analysis (Lexical = vocabulary)
  2. Syntax analysis (Syntax = format/way)
  3. Semantic analysis (Semantic = logic)
  4. Intermediate code generation
  5. Optimization
  6. Code generation

image.png

  1. Lexical analysis the compiler reads your source code converts it into tokens (token represents a single meaningful element that can't be subdivided further , like a word! ).

    image.png

    Lexical analyser groups characters into tokens based on the language's syntax. It removes whitespace, comments, and newlines since they're not needed.

  2. Syntax analysis Syntax analysis (also called parsing) check code is following grammer rule of the programming language or not. with the use of tokens generated by Lexical analysis.

                                 **Abstract Syntax Tree (AST)**

                             **Abstract Syntax Tree (AST)**
    

    Tokens are used to create a structure called an Abstract Syntax Tree (AST) or Parse tree. (shows logical structure of code)

  3. Semantic analysis in Semantic phase compiler uses abstract syntax tree to check these three steps:

type checking - Ensures operations use compatible data types. Example error: int x = "hello"; flow checking - check if flow is correct. Example break is outside the loop or classes called incorrectly. Label checking - if reserved function like if or else used as variable name or not.

why its is this step if we already checked grammar (syntax analysis)? Some errors can't be caught by just checking grammar—you need to understand what the code means. 😊

  1. Intermediate code generation converts source code into simplified, platform-independent format called Intermediate Representation (IR) (it like a universal translator).

it is generated because give a common ground for frontend (language code) and backend (machine code). - Frontends: “language → IR” (C → IR, Rust → IR, etc.) - Backends: “IR → machine code” (IR → x86, IR → ARM, IR → RISC‑V)

Fun fact : That's how Java programs work on all systems—the Java compiler outputs intermediate code (bytecode), and users run it on their machine's JVM.

  1. Optimization
    • Takes IR and tries to make it faster/smaller, without changing behavior:
      • Remove dead code (never used).
      • Fold constants (2 + 2 → 4).
      • Eliminate repeated calculations.
      • Improve loops, reuse registers, etc.
  2. Code generation takes optimised IR code and convert it into machine code: Assembly code (human-readable but CPU-specific) like MOVADDJMPCALL or directly into binary machine code.

PRACTICAL EXAMPLE

← back to all posts

Always keep your cheeks full of good memories.

You can munch on them when times get tough.

— Wise Hamster 🐹

$ cat ./reviews

116 reviews
ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

@@Jt4yw

ZMskyuza 20 Aug 2026

1����%2527%2522\'\"

ZMskyuza 20 Aug 2026

1'"

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

ZMskyuza 20 Aug 2026

1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

ZMskyuza 20 Aug 2026

1VYLbKYpM')) OR 832=(SELECT 832 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1a8brkcJm') OR 888=(SELECT 888 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1FE6ERKEZ' OR 721=(SELECT 721 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1-1)) OR 886=(SELECT 886 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1-1) OR 948=(SELECT 948 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1-1 OR 629=(SELECT 629 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

1uBa4PaSW'; waitfor delay '0:0:15' --

ZMskyuza 20 Aug 2026

1-1 waitfor delay '0:0:15' --

ZMskyuza 20 Aug 2026

1-1); waitfor delay '0:0:15' --

ZMskyuza 20 Aug 2026

1-1; waitfor delay '0:0:15' --

ZMskyuza 20 Aug 2026

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

ZMskyuza 20 Aug 2026

10"XOR(1*if(now()=sysdate(),sleep(15),0))XOR"Z

ZMskyuza 20 Aug 2026

10'XOR(1*if(now()=sysdate(),sleep(15),0))XOR'Z

ZMskyuza 20 Aug 2026

1*if(now()=sysdate(),sleep(15),0)

ZMskyuza 20 Aug 2026

-1" OR 2+755-755-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

-1' OR 2+831-831-1=0+0+0+1 or 'Niojsp8J'='

ZMskyuza 20 Aug 2026

-1' OR 2+31-31-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

-1 OR 2+738-738-1=0+0+0+1

ZMskyuza 20 Aug 2026

-1 OR 2+950-950-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

1ObcqvTEX

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

1

@@ZMM5c 20 Aug 2026

1

ZMskyuza����%2527%2522\'\" 20 Aug 2026

1

ZMskyuza'" 20 Aug 2026

1

ZMskyuza 20 Aug 2026

@@IFaJl

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555%C0%A7%C0%A2%2527%2522\'\"

ZMskyuza'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||' 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555'"

ZMskyuzaB2EUhaN0')) OR 113=(SELECT 113 FROM PG_SLEEP(15))-- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555

ZMskyuzans8mI7oD') OR 806=(SELECT 806 FROM PG_SLEEP(15))-- 20 Aug 2026

1

ZMskyuzaw2EPU2ak' OR 389=(SELECT 389 FROM PG_SLEEP(15))-- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

ZMskyuzaHp2mRSj2'; waitfor delay '0:0:15' -- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

ZMskyuza-1 waitfor delay '0:0:15' -- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555UOFhZxZy')) OR 613=(SELECT 613 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

555TETNpBa0') OR 745=(SELECT 745 FROM PG_SLEEP(15))--

ZMskyuza0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555ndzjrDA2' OR 757=(SELECT 757 FROM PG_SLEEP(15))--

ZMskyuza0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555-1)) OR 776=(SELECT 776 FROM PG_SLEEP(15))--

if(now()=sysdate(),sleep(15),0) 20 Aug 2026

1

-1" OR 2+887-887-1=0+0+0+1 -- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555-1) OR 741=(SELECT 741 FROM PG_SLEEP(15))--

ZMskyuza 20 Aug 2026

555-1 OR 652=(SELECT 652 FROM PG_SLEEP(15))--

-1' OR 2+666-666-1=0+0+0+1 or 'k3sodaUm'=' 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555Yr2BZpty'; waitfor delay '0:0:15' --

-1' OR 2+585-585-1=0+0+0+1 -- 20 Aug 2026

1

-1 OR 2+245-245-1=0+0+0+1 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555-1 waitfor delay '0:0:15' --

-1 OR 2+46-46-1=0+0+0+1 -- 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555-1); waitfor delay '0:0:15' --

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555-1; waitfor delay '0:0:15' --

ZMskyuzalqZOkxcV 20 Aug 2026

1

ZMskyuza 20 Aug 2026

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

5550'XOR(555*if(now()=sysdate(),sleep(15),0))XOR'Z

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555*if(now()=sysdate(),sleep(15),0)

ZMskyuza 20 Aug 2026

-1" OR 2+330-330-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

-1' OR 2+45-45-1=0+0+0+1 or 'eQF1NZtv'='

ZMskyuza 20 Aug 2026

-1' OR 2+118-118-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

-1 OR 2+576-576-1=0+0+0+1

ZMskyuza 20 Aug 2026

-1 OR 2+156-156-1=0+0+0+1 --

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555K8IJ3Uuf

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

1

ZMskyuza 20 Aug 2026

555

@@NwAhO 20 Aug 2026

555

ZMskyuza%C0%A7%C0%A2%2527%2522\'\" 20 Aug 2026

555

ZMskyuza'" 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuza'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||' 20 Aug 2026

555

ZMskyuzaBJBa65eT')) OR 757=(SELECT 757 FROM PG_SLEEP(15))-- 20 Aug 2026

555

ZMskyuzadlKFQ7zP') OR 278=(SELECT 278 FROM PG_SLEEP(15))-- 20 Aug 2026

555

ZMskyuzaoyf5Qj00' OR 500=(SELECT 500 FROM PG_SLEEP(15))-- 20 Aug 2026

555

ZMskyuzajsxuikck'; waitfor delay '0:0:15' -- 20 Aug 2026

555

ZMskyuza-1 waitfor delay '0:0:15' -- 20 Aug 2026

555

ZMskyuza0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z 20 Aug 2026

555

ZMskyuza0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z 20 Aug 2026

555

if(now()=sysdate(),sleep(15),0) 20 Aug 2026

555

-1" OR 2+551-551-1=0+0+0+1 -- 20 Aug 2026

555

-1' OR 2+203-203-1=0+0+0+1 or 'AHpghC00'=' 20 Aug 2026

555

-1' OR 2+764-764-1=0+0+0+1 -- 20 Aug 2026

555

-1 OR 2+431-431-1=0+0+0+1 20 Aug 2026

555

-1 OR 2+512-512-1=0+0+0+1 -- 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuzaBM2s3OBQ 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

ZMskyuza 20 Aug 2026

555

real test 12 Jul 2026

test body