Notes on linkers.
parent
87b286c358
commit
6761cc24f5
|
@ -985,7 +985,7 @@
|
||||||
"c17/linkage.md": "1e4f60f07619b9cbf2f71f11aae9e5f4",
|
"c17/linkage.md": "1e4f60f07619b9cbf2f71f11aae9e5f4",
|
||||||
"_journal/2024-11-30.md": "c6040ba2caf1c9ff55faed25d7879e9a",
|
"_journal/2024-11-30.md": "c6040ba2caf1c9ff55faed25d7879e9a",
|
||||||
"_journal/2024-11/2024-11-29.md": "4896d849b6345010669047323521e21a",
|
"_journal/2024-11/2024-11-29.md": "4896d849b6345010669047323521e21a",
|
||||||
"_journal/2024-11/2024-11-28.md": "e9d252bc4bc3d6f70db56c36e1090e86",
|
"_journal/2024-11/2024-11-28.md": "dd843bc11263a1dca3c9e27ab4fd8c68",
|
||||||
"_journal/2024-11/2024-11-27.md": "7f44f4c91fea0c5c05d542aeeb9e723d",
|
"_journal/2024-11/2024-11-27.md": "7f44f4c91fea0c5c05d542aeeb9e723d",
|
||||||
"_journal/2024-12-01.md": "d34aff07b7fa8a9a05f84841496d13b5",
|
"_journal/2024-12-01.md": "d34aff07b7fa8a9a05f84841496d13b5",
|
||||||
"_journal/2024-11/2024-11-30.md": "c6040ba2caf1c9ff55faed25d7879e9a",
|
"_journal/2024-11/2024-11-30.md": "c6040ba2caf1c9ff55faed25d7879e9a",
|
||||||
|
@ -1005,7 +1005,7 @@
|
||||||
"_journal/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
|
"_journal/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
|
||||||
"_journal/2024-12/2024-12-07.md": "bfb6c4db0acbacba19f03a04ec29fa5c",
|
"_journal/2024-12/2024-12-07.md": "bfb6c4db0acbacba19f03a04ec29fa5c",
|
||||||
"linkers/static.md": "cc56ddfc33f605d26b954ec242abc4cf",
|
"linkers/static.md": "cc56ddfc33f605d26b954ec242abc4cf",
|
||||||
"linkers/index.md": "73b07789a48be8a611941d50ae4f3831",
|
"linkers/index.md": "18d4a03aa1a94418d450a5107e7c883d",
|
||||||
"_journal/2024-12-09.md": "8988f0e8f0060f4b86d17e0bc4e7ff7e",
|
"_journal/2024-12-09.md": "8988f0e8f0060f4b86d17e0bc4e7ff7e",
|
||||||
"_journal/2024-12/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
|
"_journal/2024-12/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
|
||||||
"_journal/2024-12-10.md": "c12d380d24d7d1dc2e74a57a1b79399e",
|
"_journal/2024-12-10.md": "c12d380d24d7d1dc2e74a57a1b79399e",
|
||||||
|
@ -1024,7 +1024,10 @@
|
||||||
"_journal/2024-12/2024-12-12.md": "59e71caa4e9ebdb11a7c7549c33bed20",
|
"_journal/2024-12/2024-12-12.md": "59e71caa4e9ebdb11a7c7549c33bed20",
|
||||||
"linkers/object-files.md": "77767f310330b8650a5023dd0522226c",
|
"linkers/object-files.md": "77767f310330b8650a5023dd0522226c",
|
||||||
"_journal/2024-12-16.md": "77c27920d5b44b6315c2ea22b990eefc",
|
"_journal/2024-12-16.md": "77c27920d5b44b6315c2ea22b990eefc",
|
||||||
"_journal/2024-12/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a"
|
"_journal/2024-12/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a",
|
||||||
|
"linkers/elf.md": "83a27a7d71ca26f8f034770a31d58fa0",
|
||||||
|
"c17/strings/printf.md": "8b67cfbccaf35dd9488b73e7e5555405",
|
||||||
|
"c17/strings/index.md": "3fa6f42967f3cc786740bb8537c62682"
|
||||||
},
|
},
|
||||||
"fields_dict": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -8,4 +8,4 @@ title: "2024-11-28"
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
||||||
|
|
||||||
* Notes on [[strings#Copying Functions|memcpy and memmove]].
|
* Notes on [[c17/strings/index#Copying Functions|memcpy and memmove]].
|
|
@ -7,3 +7,5 @@ title: "2024-12-16"
|
||||||
- [ ] OGS
|
- [ ] OGS
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
||||||
|
|
||||||
|
* Notes on sections found within an [[elf|ELF]] file.
|
|
@ -0,0 +1,357 @@
|
||||||
|
---
|
||||||
|
title: Strings
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: c17
|
||||||
|
tags:
|
||||||
|
- c17
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
A contiguous sequence of characters terminated by the `NUL` character (refer to [[ascii|ASCII]]). Text data is said to be more platform-independent than [[endianness|binary]] data since it is unaffected by word size or byte ordering.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is a C-style string?
|
||||||
|
Back: A character array terminated with a `NUL` character.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1707758281264-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What character terminates all C-style strings?
|
||||||
|
Back: `NUL`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1707758281266-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the decimal value of `NUL` in ASCII encoding?
|
||||||
|
Back: `0`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1707758281268-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Text is more platform-independent than e.g. integer encodings because it is unaffected by what two properties?
|
||||||
|
Back: Word size and byte ordering.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1707758281270-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What kind of array can be expressed as a literal?
|
||||||
|
Back: Strings.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
<!--ID: 1728244147668-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
A {string} is a {`NUL`}-terminated array of {`char`}.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
<!--ID: 1728244147671-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
`<string.h>` uses prefix {`mem`} to refer to {array} arguments.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
<!--ID: 1728244147673-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
`<string.h>` uses prefix {`str`} to refer to {string} arguments.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
<!--ID: 1728244147676-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Escape Sequences
|
||||||
|
|
||||||
|
C has a standard for processing different escape sequences. Many languages built with C in mind parse these escape sequences in a similar way.
|
||||||
|
|
||||||
|
* `\ooo`: Consists of one to three octal digits.
|
||||||
|
* [[bash/index|Bash]] supports this sequence as `$'\ooo'`.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are C escape sequences for octal digits denoted?
|
||||||
|
Back: As `\ooo`.
|
||||||
|
Reference: Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language*, 2nd ed (Englewood Cliffs, N.J: Prentice Hall, 1988).
|
||||||
|
<!--ID: 1706975891805-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In C, `\ooo` allows specifying how many octal digits?
|
||||||
|
Back: One to three.
|
||||||
|
Reference: Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language*, 2nd ed (Englewood Cliffs, N.J: Prentice Hall, 1988).
|
||||||
|
<!--ID: 1706975891810-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are C escape sequences exposed in bash?
|
||||||
|
Back: Using ANSI-C quoting, i.e. `$$'string'`.
|
||||||
|
Reference: Mendel Cooper, “Advanced Bash-Scripting Guide,” n.d., 916.
|
||||||
|
Tags: bash
|
||||||
|
<!--ID: 1721387296231-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
* `\xhh`: Consists of one or more [[radices#Hexadecimal|hexadecimal]] digits. The `x` prefix is required to distinguish from octal escape sequences.
|
||||||
|
* [[bash/index|Bash]] supports this sequence as `$'\xhh'`. One or two digits is supported.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are C escape sequences for hexadecimal digits denoted?
|
||||||
|
Back: As `\xhh`.
|
||||||
|
Reference: Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language*, 2nd ed (Englewood Cliffs, N.J: Prentice Hall, 1988).
|
||||||
|
<!--ID: 1706975891820-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In C, `\x` allows specifying how many hexadecimal digits?
|
||||||
|
Back: One or more.
|
||||||
|
Reference: Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language*, 2nd ed (Englewood Cliffs, N.J: Prentice Hall, 1988).
|
||||||
|
<!--ID: 1706975891824-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What footgun does C's `\x` sequence expose?
|
||||||
|
Back: Using more than two hexadecimal digits can produce undefined results.
|
||||||
|
Reference: Arnold D. Robbins, “GAWK: Effective AWK Programming,” October 2023, [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf).
|
||||||
|
<!--ID: 1706975891828-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
* `\uhhhh`: Introduced in C11 to represent Unicode code points. *Must* have exactly four hexadecimal characters specified with `0` leading padding if necessary.
|
||||||
|
* [[bash/index|Bash]] supports this sequence as `$'uhhhh'`. One to four hex digits is supported.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What two ways are C escape sequences for unicode denoted?
|
||||||
|
Back: As `\uhhhh` or `\Uhhhhhhhh`.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
Tags: encoding::unicode
|
||||||
|
<!--ID: 1706975891832-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In C, `\u` allows specifying how many hexadecimal digits?
|
||||||
|
Back: Exactly four.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
Tags: encoding::unicode
|
||||||
|
<!--ID: 1706975891835-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what standard were C's `\u` and `\U` escape sequences introduced?
|
||||||
|
Back: C11.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
Tags: encoding::unicode
|
||||||
|
<!--ID: 1706975891839-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
* `\Uhhhhhhhh`: Introduced in C11 to represent larger unicode code points. *Must* have exactly eight hexadecimal characters specified with `0` leading padding if necessary.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In C, `\U` allows specifying how many hexadecimal digits?
|
||||||
|
Back: Exactly eight.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
Tags: encoding::unicode
|
||||||
|
<!--ID: 1706975891843-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why does C have both `\u` and `\U`?
|
||||||
|
Back: `\U` accommodates for larger code point values.
|
||||||
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
Tags: encoding::unicode
|
||||||
|
<!--ID: 1706976705750-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Copying Functions
|
||||||
|
|
||||||
|
The two primary functions used for copying memory are `memcpy` and `memmove`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
|
||||||
|
void* memmove(void* s1, const void* s2, size_t n);
|
||||||
|
```
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What are the two primary functions provided by the standard library for copying memory?
|
||||||
|
Back: `memcpy` and `memmove`.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837986-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the function prototype of `memcpy`?
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
|
||||||
|
```
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837987-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the `memcpy` function do?
|
||||||
|
Back: Copies a specified number of bytes from one object to another.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837989-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Disregarding out of bounds errors, when does `memcpy` invoke undefined behavior?
|
||||||
|
Back: When copying occurs between objects that overlap in memory.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837990-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the first argument of `memcpy` refer to?
|
||||||
|
Back: The destination address bytes are copied to.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837991-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the second argument of `memcpy` refer to?
|
||||||
|
Back: The source address bytes are copied from.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837993-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the third argument of `memcpy` refer to?
|
||||||
|
Back: The number of bytes to copy from the source address.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837994-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of `memcpy` or `memmove` is faster?
|
||||||
|
Back: `memcpy`
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837995-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* is `memmove` slower than `memcpy`?
|
||||||
|
Back: It's implemented as if copying first into a temporary array that does not overlap the arguments in memory.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837996-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
When should you prefer using `memcpy` instead of `memmove`?
|
||||||
|
Back: When the copying occurs between objects that do not overlap in memory.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837997-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which standard header library defines `memcpy`?
|
||||||
|
Back: `<string.h>`
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837998-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the function prototype of `memmove`?
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
void* memmove(void* s1, const void* s2, size_t n);
|
||||||
|
```
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843837999-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the first argument of `memmove` refer to?
|
||||||
|
Back: The destination address bytes are copied to.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838000-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the second argument of `memmove` refer to?
|
||||||
|
Back: The source address bytes are copied from.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838001-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the third argument of `memmove` refer to?
|
||||||
|
Back: The number of bytes to copy from the source address.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838002-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Disregarding out of bounds errors, when does `memmove` invoke undefined behavior?
|
||||||
|
Back: N/A.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838003-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
When should you prefer using `memmove` instead of `memcopy`?
|
||||||
|
Back: When the copying occurs between objects that overlap in memory.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838004-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which standard header library defines `memmove`?
|
||||||
|
Back: `<string.h>`
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838005-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the `memmove` function do?
|
||||||
|
Back: Copies a specified number of bytes from one object to another.
|
||||||
|
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
<!--ID: 1732843838006-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Arnold D. Robbins, “GAWK: Effective AWK Programming,” October 2023, [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf).
|
||||||
|
* Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language*, 2nd ed (Englewood Cliffs, N.J: Prentice Hall, 1988).
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
|
||||||
|
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
* Mendel Cooper, “Advanced Bash-Scripting Guide,” n.d., 916.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,331 @@
|
||||||
|
---
|
||||||
|
title: ELF
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: linker::elf x86-64
|
||||||
|
tags:
|
||||||
|
- elf
|
||||||
|
- linker
|
||||||
|
- x86-64
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Modern [[x86-64/index|x86-64]] Linux systems use the ELF (Executable and Linkable Format) object file format.
|
||||||
|
|
||||||
|
![[elf.png]]
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What object file format do modern x86-64 Linux machines typically use?
|
||||||
|
Back: ELF.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868437-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the ELF object file format an acronym for?
|
||||||
|
Back: **E**xecutable and **L**inkable **F**ormat.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868442-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is ELF an example of?
|
||||||
|
Back: An object file format.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868446-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
### Relocatable Object Files
|
||||||
|
|
||||||
|
A typical ELF relocatable object file contains the following sections:
|
||||||
|
|
||||||
|
#### `.text`
|
||||||
|
|
||||||
|
The machine code of the compiled program.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the `.text` section of an ELF file contain?
|
||||||
|
Back: The machine code of the compiled program.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304868-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section typically contains the machine code of the compiled program?
|
||||||
|
Back: `.text`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304871-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {`.text`} section contains the {machine code} of the compiled program.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304872-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
#### `.rodata`
|
||||||
|
|
||||||
|
Read-only data such as the format strings in [[c17/strings/printf|printf]] statements and [[conditions#JMP|jump tables]] for switch statements.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the `.rodata` section of an ELF file contain?
|
||||||
|
Back: Read-only data.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304874-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section typically contains read-only data?
|
||||||
|
Back: `.rodata`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304875-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why is the `.rodata` section named the way it is?
|
||||||
|
Back: It stands for **r**ead-**o**nly **data**.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304876-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what section of an ELF file would a `printf` format string be found in?
|
||||||
|
Back: `.rodata`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17::printf
|
||||||
|
<!--ID: 1734367304877-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what section of an ELF file would a jump table be found in?
|
||||||
|
Back: `.rodata`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734367304878-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
#### `.data`
|
||||||
|
|
||||||
|
Global and static C variables initialized to a non-zero value.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What kind of global/static C variables does the `.data` section of an ELF file contain?
|
||||||
|
Back: Those initialized to a non-zero value.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832070-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains global C variables initialized to a non-zero value?
|
||||||
|
Back: `.data`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832073-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains static C variables initialized to a non-zero value?
|
||||||
|
Back: `.data`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832075-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains local C variables initialized to a non-zero value?
|
||||||
|
Back: N/A.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832076-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `foo` end up in?
|
||||||
|
```c
|
||||||
|
int foo = 1;
|
||||||
|
```
|
||||||
|
Back: `.data`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188095-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `bar` end up in?
|
||||||
|
```c
|
||||||
|
int foo() {
|
||||||
|
int bar = 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: N/A.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188101-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `bar` end up in?
|
||||||
|
```c
|
||||||
|
int foo() {
|
||||||
|
static int bar = 1;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: `.data`.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188110-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
#### `.bss`
|
||||||
|
|
||||||
|
Uninitialized global and static C variables, along with any global or static variables initialized to zero.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What kind of global/static C variables does the `.bss` section of an ELF file contain?
|
||||||
|
Back: Unitialized variables or those initialized to zero.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832077-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains uninitialized global C variables?
|
||||||
|
Back: `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832078-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains global C variables initialized to a zero value?
|
||||||
|
Back: `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832079-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which two ELF sections contain global/static C variables?
|
||||||
|
Back: `.data` and `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734368832080-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `foo` end up in?
|
||||||
|
```c
|
||||||
|
int foo = 0;
|
||||||
|
```
|
||||||
|
Back: `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188113-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `foo` end up in?
|
||||||
|
```c
|
||||||
|
int foo;
|
||||||
|
```
|
||||||
|
Back: `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188117-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Both `.bss` and `.data` hold what kind of C variables?
|
||||||
|
Back: Global or static C variables.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188121-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of `.data` and/or `.bss` is considered a placeholder?
|
||||||
|
Back: `.bss`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188126-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does Bryant et al. mean by saying `.bss` is "merely a placeholder"?
|
||||||
|
Back: The `.bss` section occupies no actual space in the object file.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188131-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How does the size of the `.bss` section compare to that of the `.data` section?
|
||||||
|
Back: Less than or equal since the `.bss` section is always empty.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188136-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What mneumonic does Bryant et al. suggest to remember the `.bss` and `.data` distinction?
|
||||||
|
Back: `.bss` is a backronym for "**B**etter **S**ave **S**pace!"
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188140-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider the following translation unit. Which ELF section will `bar` end up in?
|
||||||
|
```c
|
||||||
|
int foo() {
|
||||||
|
static int bar = 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: `.bss`.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734369188106-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
#### `.symtab`
|
||||||
|
|
||||||
|
A symbol table with information about functions and global variables defined and referenced in the program.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the `.symtab` section of an ELF file contain?
|
||||||
|
Back: A symbol table for functions and global variables.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734370180072-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which ELF section contains a symbol table for functions and global variables?
|
||||||
|
Back: `.symtab`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734370180078-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why is the `.symtab` ELF section named the way it is?
|
||||||
|
Back: It's short for **sym**bol **tab**le.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734370180083-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
|
@ -99,6 +99,99 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
||||||
<!--ID: 1733671136117-->
|
<!--ID: 1733671136117-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
## Object Files
|
||||||
|
|
||||||
|
Object files come in three forms:
|
||||||
|
|
||||||
|
1. **Relocatable object files**. Contains binary code and data in a form that can be combined with other relocatable object files at compile time.
|
||||||
|
2. **Executable object files**. Contains binary code and data in a form that can be copied directly into memory and executed.
|
||||||
|
3. **Shared object files**. A special type of relocatable object file that can be loaded into memory and linked dynamically, at either load time or run time.
|
||||||
|
|
||||||
|
An **object module** is a sequence of bytes whereas an **object file** is an object module stored on disk.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What are the three types of object files?
|
||||||
|
Back: Relocatable, executable, and shared.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868367-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Relocatable object files are outputs of which compiler driver component?
|
||||||
|
Back: The assembler.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1734356868394-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Executable object files are outputs of which compiler driver component?
|
||||||
|
Back: The linker.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1734356868399-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Relocatable object files are inputs into which compiler driver component?
|
||||||
|
Back: The linker.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1734356868403-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Executable object files are inputs into which compiler driver component?
|
||||||
|
Back: N/A.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1734356868406-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
A {shared} object file is a special case of a {relocatable} object file.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868428-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is an object module?
|
||||||
|
Back: A sequence of bytes.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868413-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In terms of object modules, what is an object file?
|
||||||
|
Back: An object module stored on disk.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868418-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What distinguishes an object module from an object file?
|
||||||
|
Back: An object file is an object module stored on disk.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868423-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what way is the term "object file" misused by Bryant et al.?
|
||||||
|
Back: Technically this term only refers to object modules on disk.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1734356868433-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
@ -1,138 +0,0 @@
|
||||||
---
|
|
||||||
title: Object Files
|
|
||||||
TARGET DECK: Obsidian::STEM
|
|
||||||
FILE TAGS: linker::object-file
|
|
||||||
tags:
|
|
||||||
- linker
|
|
||||||
- object-file
|
|
||||||
---
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
Object files come in three forms:
|
|
||||||
|
|
||||||
1. **Relocatable object files**. Contains binary code and data in a form that can be combined with other relocatable object files at compile time.
|
|
||||||
2. **Executable object files**. Contains binary code and data in a form that can be copied directly into memory and executed.
|
|
||||||
3. **Shared object files**. A special type of relocatable object file that can be loaded into memory and linked dynamically, at either load time or run time.
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What are the two types of object files?
|
|
||||||
Back: Relocatable and executable.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868367-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
Relocatable object files are outputs of which compiler driver component?
|
|
||||||
Back: The assembler.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: c17
|
|
||||||
<!--ID: 1734356868394-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
Executable object files are outputs of which compiler driver component?
|
|
||||||
Back: The linker.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: c17
|
|
||||||
<!--ID: 1734356868399-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
Relocatable object files are inputs into which compiler driver component?
|
|
||||||
Back: The linker.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: c17
|
|
||||||
<!--ID: 1734356868403-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
Executable object files are inputs into which compiler driver component?
|
|
||||||
Back: N/A.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: c17
|
|
||||||
<!--ID: 1734356868406-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Cloze
|
|
||||||
A {shared} object file is a special case of a {relocatable} object file.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868428-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
An **object module** is a sequence of bytes whereas an **object file** is an object module stored on disk.
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What is an object module?
|
|
||||||
Back: A sequence of bytes.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868413-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
In terms of object modules, what is an object file?
|
|
||||||
Back: An object module stored on disk.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868418-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What distinguishes an object module from an object file?
|
|
||||||
Back: An object file is an object module stored on disk.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868423-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
In what way is the term "object file" misused by Bryant et al.?
|
|
||||||
Back: Technically this term only refers to object modules on disk.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1734356868433-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
Object files are organized to specific **object file formats**:
|
|
||||||
|
|
||||||
* Windows uses the PE (Portable Executable) format.
|
|
||||||
* Mac OS-X uses the Mach-O format.
|
|
||||||
* Modern x86-64 Linux systems use the ELF (Executable and Linkable Format) format.
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What object file format do x86-64 Linux machines typically use?
|
|
||||||
Back: ELF.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: x86-64
|
|
||||||
<!--ID: 1734356868437-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What is the ELF object file format an acronym for?
|
|
||||||
Back: **E**xecutable and **L**inkable **F**ormat.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: x86-64
|
|
||||||
<!--ID: 1734356868442-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What is ELF an example of?
|
|
||||||
Back: An object file format.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
Tags: x86-64
|
|
||||||
<!--ID: 1734356868446-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
## Bibliography
|
|
||||||
|
|
||||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
Loading…
Reference in New Issue