Cirrus Logic CS485 Manual do Utilizador Página 3

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 67
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 2
CS485G Spring 2015 3
(d) Operating systems need to deal with the intricacies of machine
code as they manipulate processes (keeping track of floating
point registers, the program counter, memory mapping tables)
(e) Malware is often written in x86 assembler.
4 Memory-referencing bugs
1. C (and C++) are subject to memory-referencing bugs.
(a) Array references out of bounds. Example (the actual result is
architecture-specific; the results shown are on x86 64)
1 void fun(int index)
2 {
3 volatile double d[1] = {3.14};
4 volatile long int a[2];
5 a[index] = 9223372036854775803L; // index out of bounds?
6 printf("%lf\n", d[0]);
7 }
8 fun(0); // 3.14
9 fun(1); // 3.14
10 fun(-1); // 3.14
11 fun(-2); // 0.0
12 fun(2); // nan (not a number)
13 fun(-3); // 3.14
14 fun(3); // 3.14 followed by fault during the return
Reason: a and d are adjacent on the stack. When you go past the
end of a, you might modify d, or you might access saved state
on the stack, ruining the return address.
(b) Lecture 2, 1/16/2015 : lab 1
(c) Lecture 3, 1/21/2015
(d) Dereferencing invalid pointers
(e) Improper allocating and deallocating memory regions
(f) Unfortunately, the symptoms may be unrelated to the causes,
and the effect might be visible only long after it is generated.
(g) Some languages prevent such errors: Java, Ruby, Haskell, ML,
but they are not usually used for systems programming.
Vista de página 2
1 2 3 4 5 6 7 8 ... 66 67

Comentários a estes Manuais

Sem comentários