Data and Program Representation Flashcards
Memory contains address from ___ to ___ for 32 bit architecture.
0, 2^32 - 1 // 0 to 4GB -1
Memory sections:
Text is for ___.
Instructions that the program runs
Memory sections:
Data is for ___.
Initialized global variables
Memory sections:
Rodata is for ___.
Read Only Data. String constants
Memory sections:
Bss is for ___.
Uninitialized global variables. They are initialized to 0
Memory sections:
Heap is for ___.
Storing the memory returned when calling malloc/new
Memory sections:
Stack is for ___.
Storing local variables and return addresses
Heap grows __, stack grows __.
upwards; downwards
There will never be gaps that do not have any memory mapping.
True/False
False.
SEGV Signal if occurs
A program includes \_\_\_. (5 items):- Machine \_\_\_\_ Initialized \_\_\_ Library \_\_\_\_ Memory \_\_\_ that the program will use Undefined \_\_\_ in the executable that will be known until the program is loaded into memory
instruction, data, dependencies, sections, values
File formats:
ELF = ?
Executable Link File
File formats:
COFF = ?
Common Object File Format
Match the file formats to their descriptions (ELF, COFF, a.out).
- Used in most UNIX systems
- Used in early UNIX; very restrictive
- Used in Windows Systems
ELF, a.out, COFF
1: After a program is written, the preprocessor expands ____ and generates ____ file.
preprocessor statements, .i
2: The compiler compiles .i file, ____ it and generates an ____ listing __ file.
optimizes, assembly instruction, .s
3: The assembler ___ .s file and generates an ___ file.
assembles, .o
4: The ___ put together all .o files and the .o files in ____ libraries.
linker, shared
The linker verifies the ___ needed by the program are satisfied, if not, ___.
symbols, error occurs
____ (.a files) are added to the executable, ___ (.so files) are not added to the executable files.
static libraries, shared libraries
Loader is a program used to run an ___ file in a process.
executable
Before running, a loader ______.
allocate spaces for all the memory sections of the executable file
If not loaded yet, a loader loads ___ and ___ into memory.
the executable, shared libraries
Once memory image is ready, the loader jumps to the ___ entry point that calls ___ of all libraries and ___ static instructors.
_start; init(); initializes
_start also calls ___ when main() returns.
exit()
Loader is also called ___ or ___.
runtime linker; dynamic linker
___ are shared across different processes, while ___ are not shared.
Shared libraries; static libraries
Pointer is a variable that contains an ___ in memory.
address
In 32-bits architecture, pointer is ___ bytes; 64-bits architecture, pointer is ___ bytes.
4; 8
It does not matter if the pointer is pointing to a valid memory before assigning or getting any value from the location.
True/False
False. Pointer must point to valid memory.
Strdup() is the only string function that allocates memory.
True/False
True
String is a sequence of characters in ASCII terminated by a ___.
‘\0’
a[i] = ?
- ((int) (char)&a[0] + isizeof(int)))
int **a is a valid 2D array implementation.
Initialize a with malloc sizeof (int*), then for each row, initialize each row with sizeof(int).
True
Pointer to functions are used to implement ___.
Polymorphism
Bit stores __ or __.
1, 0
Byte is a group of __ bits that can be individually addressable.
8
Word is __ bytes (32-bits architecture) / __ bytes (64-bits architecture).
4, 8
EBCDIC = ?
Extended Binary Coded Decimal Interchange Format
ASCII = ?
American Standard Code for Information Exchange
Match each description with their character encodings (EBCDIC, ASCII, UNICODE).
- Only encodes the English alphabet; 7 bits
- Java and C#; represents characters from most languages; 16 bits long
- Created by IBM
ASCII
UNICODE
EBCDIC
In using sign and magnitude to represent negative integer number, __ bit for sign, other bits for ____.
1; absolute value
In 1-Complement, negative integers are represented by ___.
Inverting all bits
In 2-complement, we ___ from positive number and ___ the result.
subtract 1; invert
2-complement is widely used because ___.
The same piece of hardware used for positive numbers can be used for negative numbers
In floating point representation, the exponent is calculated by ___.
exponent - bias
Little endian - ____ significant byte at the lowest memory location.
Big endian - ____ significant byte at the lowest memory location.
least; most
Structure is a combination in memory of ___.
primitive types
In alignment for structures (32-bit architecture), integers, float, and pointers have to be aligned to ___ bytes.
4
If the types are not aligned in structure ___ or ___ will occur.
Bus error; slow down execution