Notes on `COMMON` and other pseudosections.

main
Joshua Potter 2024-12-27 16:58:17 -07:00
parent f4c9de78c5
commit 0f87d64329
4 changed files with 354 additions and 35 deletions

View File

@ -1029,7 +1029,7 @@
"linkers/object-files.md": "77767f310330b8650a5023dd0522226c", "linkers/object-files.md": "77767f310330b8650a5023dd0522226c",
"_journal/2024-12-16.md": "d867a62a955f3d080ae25f31464d53c4", "_journal/2024-12-16.md": "d867a62a955f3d080ae25f31464d53c4",
"_journal/2024-12/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a", "_journal/2024-12/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a",
"linkers/elf.md": "46e6b1ae505a198eedc336e9ef54e419", "linkers/elf.md": "6b54c2628bcd6e39df9cf3d09a68b62b",
"c17/strings/printf.md": "8b67cfbccaf35dd9488b73e7e5555405", "c17/strings/printf.md": "8b67cfbccaf35dd9488b73e7e5555405",
"c17/strings/index.md": "3fa6f42967f3cc786740bb8537c62682", "c17/strings/index.md": "3fa6f42967f3cc786740bb8537c62682",
"_journal/2024-12-17.md": "ae55db66c9835876c4a0343ac0806951", "_journal/2024-12-17.md": "ae55db66c9835876c4a0343ac0806951",
@ -1065,11 +1065,11 @@
"_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279", "_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279",
"_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
"_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d", "_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d",
"linkers/relocatable.md": "fa89f08afe9a54d7b4e6374282983753", "linkers/relocatable.md": "df8ceb9739969516b6fb6b35dc8d208e",
"data-models/federation.md": "1d92747304186bd2833a00a488fcac48", "data-models/federation.md": "1d92747304186bd2833a00a488fcac48",
"_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41", "_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41",
"_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
"_journal/2024-12-27.md": "acb4db426b352cb7b90194ef73ce05e5", "_journal/2024-12-27.md": "abc4a39a50305f3558181189eefb2058",
"_journal/2024-12/2024-12-26.md": "59e59cad1ae568adbe8e27e98d36c59c" "_journal/2024-12/2024-12-26.md": "59e59cad1ae568adbe8e27e98d36c59c"
}, },
"fields_dict": { "fields_dict": {

View File

@ -4,6 +4,8 @@ title: "2024-12-27"
- [x] Anki Flashcards - [x] Anki Flashcards
- [x] KoL - [x] KoL
- [ ] OGS - [x] OGS
- [ ] Sheet Music (10 min.) - [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
* Notes on relocatable object file [[relocatable#Pseudosections|pseudosections]].

View File

@ -46,7 +46,7 @@ The machine code of the compiled program.
%%ANKI %%ANKI
Basic Basic
What does the `.text` section of an ELF file contain? What does the `.text` section contain?
Back: The machine code of the compiled program. 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734367304868--> <!--ID: 1734367304868-->
@ -62,7 +62,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
The {`.text`} section contains the {machine code} of the compiled program. The {`.text`} ELF 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734367304872--> <!--ID: 1734367304872-->
END%% END%%
@ -73,7 +73,7 @@ Read-only data such as the format strings in [[c17/strings/printf|printf]] state
%%ANKI %%ANKI
Basic Basic
What does the `.rodata` section of an ELF file contain? What does the `.rodata` section contain?
Back: Read-only data. 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734367304874--> <!--ID: 1734367304874-->
@ -97,7 +97,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
In what section of an ELF file would a `printf` format string be found in? In what ELF section would a `printf` format string be found in?
Back: `.rodata` Back: `.rodata`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. 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 Tags: c17::printf
@ -106,7 +106,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
In what section of an ELF file would a jump table be found in? In what ELF section would a jump table be found in?
Back: `.rodata` Back: `.rodata`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734367304878--> <!--ID: 1734367304878-->
@ -118,7 +118,7 @@ Global and static C variables initialized to a non-zero value.
%%ANKI %%ANKI
Basic Basic
What kind of global/static C variables does the `.data` section of an ELF file contain? What kind of global/static C variables does the `.data` section contain?
Back: Those initialized to a non-zero value. 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
@ -198,7 +198,7 @@ Thread-local global and static C variables initialized to a non-zero value.
%%ANKI %%ANKI
Basic Basic
What kind of global/static C variables does the `.tdata` section of an ELF file contain? What kind of global/static C variables does the `.tdata` section contain?
Back: Thread-local variables initialized to a non-zero value. Back: Thread-local variables initialized to a non-zero value.
Reference: Ulrich Drepper, “ELF Handling For Thread-Local Storage,” n.d. Reference: Ulrich Drepper, “ELF Handling For Thread-Local Storage,” n.d.
Tags: c17 Tags: c17
@ -265,12 +265,12 @@ END%%
### `.bss` ### `.bss`
Uninitialized global and static C variables, along with any global or static variables initialized to zero. Assuming `-fno-common`, contains global and static C variables, along with any global or static variables initialized to zero.
%%ANKI %%ANKI
Basic Basic
What kind of global/static C variables does the `.bss` section of an ELF file contain? Assuming `-fno-common`, what kind of C variables does the `.bss` section contain?
Back: Unitialized variables or those initialized to zero. Back: Uninitialized global and static 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
<!--ID: 1734368832077--> <!--ID: 1734368832077-->
@ -278,7 +278,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Which ELF section contains uninitialized global C variables? Assuming `-fno-common`, which ELF section contains uninitialized global C variables?
Back: `.bss` Back: `.bss`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
@ -287,7 +287,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Which ELF section contains global C variables initialized to a zero value? Assuming `-fno-common`, which ELF section contains global C variables initialized to a zero value?
Back: `.bss` Back: `.bss`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
@ -296,7 +296,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Which two ELF sections contain global/static C variables? Assuming `-fno-common`, which two ELF sections contain global and static C variables?
Back: `.data` and `.bss` 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
@ -305,7 +305,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Consider the following translation unit. Which ELF section will `foo` end up in? Consider the following translation unit. Assuming `-fno-common`, which ELF section will `foo` end up in?
```c ```c
int foo = 0; int foo = 0;
``` ```
@ -317,7 +317,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Consider the following translation unit. Which ELF section will `foo` end up in? Consider the following translation unit. Assuming `-fno-common`, which ELF section will `foo` end up in?
```c ```c
int foo; int foo;
``` ```
@ -329,8 +329,8 @@ END%%
%%ANKI %%ANKI
Basic Basic
Both `.bss` and `.data` hold what kind of C variables? Assuming `-fno-common`, both `.bss` and `.data` hold what kind of C variables?
Back: Global or static variables. Back: Global and static variables.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
<!--ID: 1734369188121--> <!--ID: 1734369188121-->
@ -370,14 +370,14 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
{Block started by symbol} is the actual acronym for Bryan et al.'s mneumonic {better save space}. {Block started by symbol} is the actual acronym for Bryant et al.'s mneumonic {better save space}.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735155720954--> <!--ID: 1735155720954-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
Consider the following translation unit. Which ELF section will `bar` end up in? Consider the following translation unit. Assuming `-fno-common`, which section will `bar` end up in?
```c ```c
int foo() { int foo() {
static int bar = 0; static int bar = 0;
@ -395,7 +395,7 @@ Uninitialized global and static thread-local C variables, along with any global
%%ANKI %%ANKI
Basic Basic
What kind of global/static C variables does the `.tbss` section of an ELF file contain? What kind of global/static C variables does the `.tbss` section contain?
Back: Unitialized thread-local variables or those initialized to zero. Back: Unitialized thread-local variables or those initialized to zero.
Reference: Ulrich Drepper, “ELF Handling For Thread-Local Storage,” n.d. Reference: Ulrich Drepper, “ELF Handling For Thread-Local Storage,” n.d.
Tags: c17 Tags: c17
@ -500,7 +500,7 @@ A symbol table with information about functions and global variables defined and
%%ANKI %%ANKI
Basic Basic
What does the `.symtab` section of an ELF file contain? What does the `.symtab` section contain?
Back: A symbol table for functions and global variables. 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734370180072--> <!--ID: 1734370180072-->
@ -516,7 +516,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why is the `.symtab` ELF section named the way it is? Why is the `.symtab` section named the way it is?
Back: It's short for **sym**bol **tab**le. 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734370180083--> <!--ID: 1734370180083-->
@ -528,7 +528,7 @@ A list of locations in the `.text` section that will need to be modified when th
%%ANKI %%ANKI
Basic Basic
What does the `.rel.text` section of an ELF file contain? What does the `.rel.text` section contain?
Back: Relocation entries for the `.text` section. Back: Relocation entries for the `.text` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879344--> <!--ID: 1734456879344-->
@ -536,7 +536,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why is the `.rel.text` ELF section named the way it is? Why is the `.rel.text` section named the way it is?
Back: It's short for **rel**ocation entries for the `.text` section. Back: It's short for **rel**ocation entries for the `.text` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879386--> <!--ID: 1734456879386-->
@ -544,7 +544,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
The {`.rel.text`} section contains {relocation entries} for the `.text` section. The {`.rel.text`} ELF section contains {relocation entries} for the `.text` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879393--> <!--ID: 1734456879393-->
END%% END%%
@ -555,7 +555,7 @@ A list of locations in the `.data` section that will need to be modified when th
%%ANKI %%ANKI
Basic Basic
What does the `.rel.data` section of an ELF file contain? What does the `.rel.data` section contain?
Back: Relocation entries for the `.data` section. Back: Relocation entries for the `.data` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879404--> <!--ID: 1734456879404-->
@ -563,7 +563,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why is the `.rel.data` ELF section named the way it is? Why is the `.rel.data` section named the way it is?
Back: It's short for **rel**ocation entries for the `.data` section. Back: It's short for **rel**ocation entries for the `.data` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879407--> <!--ID: 1734456879407-->
@ -571,7 +571,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
The {`.rel.data`} section contains {relocation entries} for the `.data` section. The {`.rel.data`} ELF section contains {relocation entries} for the `.data` section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879414--> <!--ID: 1734456879414-->
END%% END%%
@ -582,7 +582,7 @@ A string table for the symbol tables in the `.symtab` section as well as for sec
%%ANKI %%ANKI
Basic Basic
What does the `.strtab` section of an ELF file contain? What does the `.strtab` section contain?
Back: A string table. Back: A string table.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879418--> <!--ID: 1734456879418-->
@ -590,7 +590,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why is the `.strtab` ELF section named the way it is? Why is the `.strtab` section named the way it is?
Back: It is short for **str**ing **tab**le. Back: It is short for **str**ing **tab**le.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734456879422--> <!--ID: 1734456879422-->

View File

@ -124,6 +124,323 @@ Tags: c17
<!--ID: 1735159138677--> <!--ID: 1735159138677-->
END%% END%%
## Pseudosections
There are three special pseudosections specified in the section header table that do not have entries in the section header table. Note pseudosections only exist in relocatable object files.
%%ANKI
Basic
How many types of pseudosections can be found in relocatable object files?
Back: Three.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812817-->
END%%
%%ANKI
Basic
How many types of pseudosections can be found in executable object files?
Back: Zero.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812819-->
END%%
%%ANKI
Basic
What are the three pseudosections possibly found in relocatable object files?
Back: ABS, UNDEF, and COMMON.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812820-->
END%%
%%ANKI
Basic
In what region of an ELF file can references to pseudosections be found?
Back: The section header table.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812821-->
END%%
%%ANKI
Basic
Why are ELF pseudosections named the way they are?
Back: They don't actually correspond to any ELF section.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343872318-->
END%%
### `ABS`
Marks symbols that should not be relocated.
%%ANKI
Basic
What does the ABS pseudosection indicate?
Back: The corresponding symbol should not be relocated.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812822-->
END%%
%%ANKI
Basic
Why is the ABS pseudosection named the way it is?
Back: It's short for **abs**olute.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812823-->
END%%
### `UNDEF`
Marks undefined symbols. These are referenced in the object module but (presumably) defined elsewhere.
%%ANKI
Basic
What does the UNDEF pseudosection indicate?
Back: The corresponding symbol is (presumably) defined elsewhere.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812824-->
END%%
%%ANKI
Basic
Why is the UNDEF pseudosection named the way it is?
Back: It's short for **undef**ined.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812825-->
END%%
### `COMMON`
Assuming `-fcommon`, marks unitialized data objects that are not yet allocated.
%%ANKI
Basic
What does the `COMMON` pseudosection indicate?
Back: The corresponding symbol is uninitialized and not yet allocated.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812826-->
END%%
%%ANKI
Basic
What C variables are marked `COMMON` instead of put in `.bss`?
Back: Global uninitialized variables.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812827-->
END%%
%%ANKI
Basic
What C variables are put in `.bss` instead of marked `COMMON`?
Back: Static variables or global variables 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: 1735343812828-->
END%%
%%ANKI
Basic
Assuming `-fcommon`, what kind of C variables does the `.bss` section contain?
Back: Static variables or global and static variables 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.
Tags: c17
<!--ID: 1735343812829-->
END%%
%%ANKI
Basic
Assuming `-fcommon`, what kind of C variables does the `COMMON` section contain?
Back: Global uninitialized variables.
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: 1735343812830-->
END%%
%%ANKI
Basic
Assuming `-fcommon`, which ELF section contains uninitialized global C variables?
Back: N/A. These are "placed" into the `COMMON` pseudosection.
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: 1735343812831-->
END%%
%%ANKI
Basic
Assuming `-fcommon`, 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.
Tags: c17
<!--ID: 1735343812832-->
END%%
%%ANKI
Basic
Consider the following translation unit. Assuming `-fcommon`, 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.
Tags: c17
<!--ID: 1735343812833-->
END%%
%%ANKI
Basic
Consider the following translation unit. Assuming `-fcommon`, which ELF section will `foo` end up in?
```c
int foo;
```
Back: N/A. It is "placed" into the `COMMON` pseudosection.
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: 1735343812834-->
END%%
At compile time, the compiler exports each global symbol as either **strong** or **weak**, and the assembler encodes this information in the symbol table. Functions and initialized global variables get strong symbols whereas uninitialized global variables get weak symbols. The linker then resolves global symbols as follows:
1. Multiple strong symbols with the same name are not allowed.
2. Given a strong symbol and multiple weak symbols with the same name, choose the strong symbol.
3. Given multiple weak symbols with the same name, choose *any* of the weak symbols.
%%ANKI
Basic
Assuming `-fcommon`, global symbols are further categorized into what two buckets?
Back: Strong and weak.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812835-->
END%%
%%ANKI
Basic
Which component of the compiler driver indicates whether a global variable is strong or weak?
Back: The compiler.
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: 1735343812836-->
END%%
%%ANKI
Basic
Does a function correspond to a strong or weak symbol?
Back: Strong.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812837-->
END%%
%%ANKI
Basic
Does a globally initialized variable correspond to a strong or weak symbol?
Back: Strong.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812838-->
END%%
%%ANKI
Basic
Does a globally uninitialized variable correspond to a strong or weak symbol?
Back: Weak.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812839-->
END%%
%%ANKI
Basic
Does a static variable correspond to a strong or weak symbol?
Back: N/A. Strong and weak describe 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: 1735343812840-->
END%%
%%ANKI
Basic
Is `foo` considered strong or weak in the following translation unit?
```c
int foo;
```
Back: Weak.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812841-->
END%%
%%ANKI
Basic
Is `foo` considered strong or weak in the following translation unit?
```c
int foo = 0;
```
Back: Strong.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812842-->
END%%
%%ANKI
Basic
Is `foo` considered strong or weak in the following translation unit?
```c
int foo = 1;
```
Back: Strong.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812843-->
END%%
%%ANKI
Basic
Is `foo` considered strong or weak in the following translation unit?
```c
int foo();
```
Back: Strong.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812844-->
END%%
%%ANKI
Basic
How does a linker resolve multiple strong symbols with the same name?
Back: N/A. It throws an error.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812845-->
END%%
%%ANKI
Basic
How does a linker resolve one strong symbol and multiple weak symbols with the same name?
Back: It prefers the strong symbol.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812846-->
END%%
%%ANKI
Basic
How does a linker resolve one weak symbol and multiple strong symbols with the same name?
Back: N/A. It throws an error.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812847-->
END%%
%%ANKI
How does a linker resolve multiple weak symbols with the same name?
Back: By arbitrarily picking one.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
END%%
%%ANKI
Cloze
Assuming `-fcommon`, {1:strong} is to {2:`.bss`} whereas {2:weak} is to {1:`COMMON`}.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1735343812848-->
END%%
%%ANKI
Basic
Why is `COMMON` considered in conflict with the C standard?
Back: C only allows a single definition for any object.
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: 1735343812849-->
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.