SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
Finding Buffer Overflows
Generating Loops
Magistère Informatique de Grenoble 2015,
Claude Goubet
VERIMAG (supervisor L. Mounier)
Vulnerabilities and buffer overflow
A vulnerability is a particular case of a
bug, when it can be used in order to lead
the program to have an unexpected
behavior.
A buffer overflow is a vulnerability which
appears when a program, writing data in a
buffer, overruns its boundary and
overwrites the adjacent memory locations.
2
How can a buffer overflow appear?
3
strcpy(char *s1, const char
*s2)
{
char *s = s1;
while ((*s++ = *s2++) !=
0)
;
return (s1);
}
How can a buffer overflow appear?
strcpy(char *s1, const char
*s2)
{
char *s = s1;
while ((*s++ = *s2++) !=
0)
;
return (s1);
} .While:
movl -4(%ebp),
%eax
movzbl (%eax), %edx
movl -8(%ebp),
%eax
movb %dl, (%eax)
movl -8(%ebp),
%eax
movzbl (%eax), %eax
testb %al, %al
setne %al
addl $1, -8(%ebp)
addl $1, -4(%ebp)
testb %al, %al
top
S2’s
pointer
S1’s
pointer
Return
address
s2
s1
Return
address
High addresses
5
How can a buffer overflow appear?
strcpy(char *s1, const char
*s2)
{
char *s = s1;
while ((*s++ = *s2++) !=
0)
;
return (s1);
} .While:
movl -4(%ebp),
%eax
movzbl (%eax), %edx
movl -8(%ebp),
%eax
movb %dl, (%eax)
movl -8(%ebp),
%eax
movzbl (%eax), %eax
testb %al, %al
setne %al
addl $1, -8(%ebp)
addl $1, -4(%ebp)
testb %al, %al
top
S2’s
pointer
S1’s
pointer
Return
address
s2
s1
Return
address
High addresses
top
S2’s
pointer
S1’s
pointer
Return
address
s2
High addresses
s2
A litle history
1996: « Smashing the stack for fun and
profit », Aleph One
1997: non-executable (NX) stack
countermeasure, Alexander Peslyak on the
linux Kernel
1997: non-executable stack attacks using
library calls
2000: NX improvement: randomisation of the
mmap base, PAX team
2001: attacks on PAX
… 6
Static buffer overflow
detection
Static analysis :
No program execution
Assambly code
Detection principle :
Loop detection
Inner loop data-dependency analysis
7
Loop detection
8
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Loop detection
9
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Control flow
graph
Loop detection
10
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Control flow
graph
Back edges
Loop detection
11
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Control flow
graph
Inner loops
Loop detection
12
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Control flow
graph
Nesting loop
Loop detection
13
int main () {
int x = 0;
while (x != 1)
{
if (x < 1)
x++;
else
x--;
}
while (x <=
15){
int i = 0 ;
while (i < 3)
{
x++;
i++;
}
}
return 0;
}
Control flow
graph
Nested loop
Dataflow analysis
14
.While:
movl -4(%ebp),
%eax
movzbl (%eax), %edx
movl -8(%ebp),
%eax
movb %dl, (%eax)
movl -8(%ebp),
%eax
movzbl (%eax), %eax
testb %al, %al
setne %al
addl $1, -8(%ebp)
addl $1, -4(%ebp)
testb %al, %al
jne .While

Weitere ähnliche Inhalte

Was ist angesagt?

CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)jon_bell
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory ManagementAlan Uthoff
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operatorsHarleen Sodhi
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...akaptur
 
Python opcodes
Python opcodesPython opcodes
Python opcodesalexgolec
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLJonas Traub
 
Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9ecomputernotes
 
Artificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosiesArtificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosiesFoCAS Initiative
 
Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Eventsztellman
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterakaptur
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38ecomputernotes
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
A compact zero knowledge proof to restrict message space in homomorphic encry...
A compact zero knowledge proof to restrict message space in homomorphic encry...A compact zero knowledge proof to restrict message space in homomorphic encry...
A compact zero knowledge proof to restrict message space in homomorphic encry...MITSUNARI Shigeo
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingMatsuo and Tsumura lab.
 
Javascript Basics for Advertisers
Javascript Basics for AdvertisersJavascript Basics for Advertisers
Javascript Basics for AdvertisersTom Crinson
 

Was ist angesagt? (20)

CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory Management
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCL
 
Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9
 
Artificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosiesArtificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosies
 
Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Events
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
A compact zero knowledge proof to restrict message space in homomorphic encry...
A compact zero knowledge proof to restrict message space in homomorphic encry...A compact zero knowledge proof to restrict message space in homomorphic encry...
A compact zero knowledge proof to restrict message space in homomorphic encry...
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with Multithreading
 
Scope and closures
Scope and closuresScope and closures
Scope and closures
 
Reactive x
Reactive xReactive x
Reactive x
 
Javascript Basics for Advertisers
Javascript Basics for AdvertisersJavascript Basics for Advertisers
Javascript Basics for Advertisers
 
Lrz kurse: r as superglue
Lrz kurse: r as superglueLrz kurse: r as superglue
Lrz kurse: r as superglue
 

Andere mochten auch

Andere mochten auch (12)

20100822 computervision boykov
20100822 computervision boykov20100822 computervision boykov
20100822 computervision boykov
 
CV_Virginie_Bourgery_2017
CV_Virginie_Bourgery_2017CV_Virginie_Bourgery_2017
CV_Virginie_Bourgery_2017
 
portafolio
portafolioportafolio
portafolio
 
Best stock advisory
Best stock advisoryBest stock advisory
Best stock advisory
 
RESUME-Venkataraman final
RESUME-Venkataraman finalRESUME-Venkataraman final
RESUME-Venkataraman final
 
Freire trabajo de internett (1)
Freire trabajo de internett (1)Freire trabajo de internett (1)
Freire trabajo de internett (1)
 
Измеряя неизмеримое. Об исследованиях в психотерапии
Измеряя неизмеримое. Об исследованиях в психотерапииИзмеряя неизмеримое. Об исследованиях в психотерапии
Измеряя неизмеримое. Об исследованиях в психотерапии
 
Data servis misión
Data servis misiónData servis misión
Data servis misión
 
Cтатистика, грудень 2015 року
Cтатистика, грудень 2015 рокуCтатистика, грудень 2015 року
Cтатистика, грудень 2015 року
 
La interfaz
La interfazLa interfaz
La interfaz
 
LINEAMIENTOS GENERALES "Fiesta de la Lectura"
LINEAMIENTOS GENERALES "Fiesta de la Lectura"LINEAMIENTOS GENERALES "Fiesta de la Lectura"
LINEAMIENTOS GENERALES "Fiesta de la Lectura"
 
Specific phobia
Specific phobiaSpecific phobia
Specific phobia
 

Ähnlich wie software-vulnerability-detectionPresentation

NSC #2 - D2 06 - Richard Johnson - SAGEly Advice
NSC #2 - D2 06 - Richard Johnson - SAGEly AdviceNSC #2 - D2 06 - Richard Johnson - SAGEly Advice
NSC #2 - D2 06 - Richard Johnson - SAGEly AdviceNoSuchCon
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)Henry Muccini
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Michael Barker
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITEgor Bogatov
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)yap_raiza
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simplerAlexander Mostovenko
 
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...GeeksLab Odessa
 
PBL1-v1-004j.pptx
PBL1-v1-004j.pptxPBL1-v1-004j.pptx
PBL1-v1-004j.pptxNAIST
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemSages
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...Positive Hack Days
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CSusumu Tokumoto
 
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법NAVER Engineering
 
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...Iosif Itkin
 

Ähnlich wie software-vulnerability-detectionPresentation (20)

Marat-Slides
Marat-SlidesMarat-Slides
Marat-Slides
 
3
33
3
 
NSC #2 - D2 06 - Richard Johnson - SAGEly Advice
NSC #2 - D2 06 - Richard Johnson - SAGEly AdviceNSC #2 - D2 06 - Richard Johnson - SAGEly Advice
NSC #2 - D2 06 - Richard Johnson - SAGEly Advice
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
PBL1-v1-004j.pptx
PBL1-v1-004j.pptxPBL1-v1-004j.pptx
PBL1-v1-004j.pptx
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for C
 
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법
기계학습을 이용하여 정적 분석기의 안전성을 선별적으로 조절하는 방법
 
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015
 
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
 

software-vulnerability-detectionPresentation

  • 1. Finding Buffer Overflows Generating Loops Magistère Informatique de Grenoble 2015, Claude Goubet VERIMAG (supervisor L. Mounier)
  • 2. Vulnerabilities and buffer overflow A vulnerability is a particular case of a bug, when it can be used in order to lead the program to have an unexpected behavior. A buffer overflow is a vulnerability which appears when a program, writing data in a buffer, overruns its boundary and overwrites the adjacent memory locations. 2
  • 3. How can a buffer overflow appear? 3 strcpy(char *s1, const char *s2) { char *s = s1; while ((*s++ = *s2++) != 0) ; return (s1); }
  • 4. How can a buffer overflow appear? strcpy(char *s1, const char *s2) { char *s = s1; while ((*s++ = *s2++) != 0) ; return (s1); } .While: movl -4(%ebp), %eax movzbl (%eax), %edx movl -8(%ebp), %eax movb %dl, (%eax) movl -8(%ebp), %eax movzbl (%eax), %eax testb %al, %al setne %al addl $1, -8(%ebp) addl $1, -4(%ebp) testb %al, %al top S2’s pointer S1’s pointer Return address s2 s1 Return address High addresses
  • 5. 5 How can a buffer overflow appear? strcpy(char *s1, const char *s2) { char *s = s1; while ((*s++ = *s2++) != 0) ; return (s1); } .While: movl -4(%ebp), %eax movzbl (%eax), %edx movl -8(%ebp), %eax movb %dl, (%eax) movl -8(%ebp), %eax movzbl (%eax), %eax testb %al, %al setne %al addl $1, -8(%ebp) addl $1, -4(%ebp) testb %al, %al top S2’s pointer S1’s pointer Return address s2 s1 Return address High addresses top S2’s pointer S1’s pointer Return address s2 High addresses s2
  • 6. A litle history 1996: « Smashing the stack for fun and profit », Aleph One 1997: non-executable (NX) stack countermeasure, Alexander Peslyak on the linux Kernel 1997: non-executable stack attacks using library calls 2000: NX improvement: randomisation of the mmap base, PAX team 2001: attacks on PAX … 6
  • 7. Static buffer overflow detection Static analysis : No program execution Assambly code Detection principle : Loop detection Inner loop data-dependency analysis 7
  • 8. Loop detection 8 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; }
  • 9. Loop detection 9 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; } Control flow graph
  • 10. Loop detection 10 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; } Control flow graph Back edges
  • 11. Loop detection 11 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; } Control flow graph Inner loops
  • 12. Loop detection 12 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; } Control flow graph Nesting loop
  • 13. Loop detection 13 int main () { int x = 0; while (x != 1) { if (x < 1) x++; else x--; } while (x <= 15){ int i = 0 ; while (i < 3) { x++; i++; } } return 0; } Control flow graph Nested loop
  • 14. Dataflow analysis 14 .While: movl -4(%ebp), %eax movzbl (%eax), %edx movl -8(%ebp), %eax movb %dl, (%eax) movl -8(%ebp), %eax movzbl (%eax), %eax testb %al, %al setne %al addl $1, -8(%ebp) addl $1, -4(%ebp) testb %al, %al jne .While