Data and Program Representation Flashcards

1
Q

Memory contains address from ___ to ___ for 32 bit architecture.

A

0, 2^32 - 1 // 0 to 4GB -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Memory sections:

Text is for ___.

A

Instructions that the program runs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Memory sections:

Data is for ___.

A

Initialized global variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Memory sections:

Rodata is for ___.

A

Read Only Data. String constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Memory sections:

Bss is for ___.

A

Uninitialized global variables. They are initialized to 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Memory sections:

Heap is for ___.

A

Storing the memory returned when calling malloc/new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Memory sections:

Stack is for ___.

A

Storing local variables and return addresses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Heap grows __, stack grows __.

A

upwards; downwards

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

There will never be gaps that do not have any memory mapping.
True/False

A

False.

SEGV Signal if occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
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
A

instruction, data, dependencies, sections, values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

File formats:

ELF = ?

A

Executable Link File

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

File formats:

COFF = ?

A

Common Object File Format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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
A

ELF, a.out, COFF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

1: After a program is written, the preprocessor expands ____ and generates ____ file.

A

preprocessor statements, .i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

2: The compiler compiles .i file, ____ it and generates an ____ listing __ file.

A

optimizes, assembly instruction, .s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

3: The assembler ___ .s file and generates an ___ file.

A

assembles, .o

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

4: The ___ put together all .o files and the .o files in ____ libraries.

A

linker, shared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The linker verifies the ___ needed by the program are satisfied, if not, ___.

A

symbols, error occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

____ (.a files) are added to the executable, ___ (.so files) are not added to the executable files.

A

static libraries, shared libraries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Loader is a program used to run an ___ file in a process.

A

executable

21
Q

Before running, a loader ______.

A

allocate spaces for all the memory sections of the executable file

22
Q

If not loaded yet, a loader loads ___ and ___ into memory.

A

the executable, shared libraries

23
Q

Once memory image is ready, the loader jumps to the ___ entry point that calls ___ of all libraries and ___ static instructors.

A

_start; init(); initializes

24
Q

_start also calls ___ when main() returns.

A

exit()

25
Q

Loader is also called ___ or ___.

A

runtime linker; dynamic linker

26
Q

___ are shared across different processes, while ___ are not shared.

A

Shared libraries; static libraries

27
Q

Pointer is a variable that contains an ___ in memory.

A

address

28
Q

In 32-bits architecture, pointer is ___ bytes; 64-bits architecture, pointer is ___ bytes.

A

4; 8

29
Q

It does not matter if the pointer is pointing to a valid memory before assigning or getting any value from the location.
True/False

A

False. Pointer must point to valid memory.

30
Q

Strdup() is the only string function that allocates memory.

True/False

A

True

31
Q

String is a sequence of characters in ASCII terminated by a ___.

A

‘\0’

32
Q

a[i] = ?

A
  • ((int) (char)&a[0] + isizeof(int)))
33
Q

int **a is a valid 2D array implementation.

Initialize a with malloc sizeof (int*), then for each row, initialize each row with sizeof(int).

A

True

34
Q

Pointer to functions are used to implement ___.

A

Polymorphism

35
Q

Bit stores __ or __.

A

1, 0

36
Q

Byte is a group of __ bits that can be individually addressable.

A

8

37
Q

Word is __ bytes (32-bits architecture) / __ bytes (64-bits architecture).

A

4, 8

38
Q

EBCDIC = ?

A

Extended Binary Coded Decimal Interchange Format

39
Q

ASCII = ?

A

American Standard Code for Information Exchange

40
Q

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
A

ASCII
UNICODE
EBCDIC

41
Q

In using sign and magnitude to represent negative integer number, __ bit for sign, other bits for ____.

A

1; absolute value

42
Q

In 1-Complement, negative integers are represented by ___.

A

Inverting all bits

43
Q

In 2-complement, we ___ from positive number and ___ the result.

A

subtract 1; invert

44
Q

2-complement is widely used because ___.

A

The same piece of hardware used for positive numbers can be used for negative numbers

45
Q

In floating point representation, the exponent is calculated by ___.

A

exponent - bias

46
Q

Little endian - ____ significant byte at the lowest memory location.
Big endian - ____ significant byte at the lowest memory location.

A

least; most

47
Q

Structure is a combination in memory of ___.

A

primitive types

48
Q

In alignment for structures (32-bit architecture), integers, float, and pointers have to be aligned to ___ bytes.

A

4

49
Q

If the types are not aligned in structure ___ or ___ will occur.

A

Bus error; slow down execution