Do the work of a linker by hand for two object files: place four sections, find four symbols and fill one hole.
Hardware context: Two object files held as arrays (six instruction words with two holes, and two data words), with a small linker and loader as test code. Building the software image of a chip, and reading a linker map
A linker joins two object files, a.o and b.o. It places the code of a.o at address 0, and the code of b.o directly after it. It places the data of a.o at address 128, and the data of b.o directly after that. All addresses and sizes here are in decimal, in bytes.
This worksheet uses named constants. The first three entries show how to record your decisions.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| File | Code section | Data section | Symbols it defines |
|---|---|---|---|
| a.o | 24 bytes | 8 bytes | main at code + 0; total at data + 4 |
| b.o | 16 bytes | 12 bytes | helper at code + 4; table at data + 0 |
Enter every value in decimal. For a yes or no question, enter 1 for yes and 0 for no.
| Entry | Your decision |
|---|---|
| CODE_BASE_OF_B | At which address does the code of b.o start? |
| ADDRESS_OF_MAIN | What is the address of main? |
| ADDRESS_OF_HELPER | What is the address of helper? |
| END_OF_CODE | What is the first address after all the code? |
| DATA_BASE_OF_B | At which address does the data of b.o start? |
| ADDRESS_OF_TOTAL | What is the address of total? |
| ADDRESS_OF_TABLE | What is the address of table? |
| END_OF_DATA | What is the first address after all the data? |
| ADDRESS_OF_THE_JAL | At which address is the jal that calls helper? |
| OFFSET_IN_THE_JAL | Which offset does the linker write into that jal? |
| RA_AFTER_THE_JAL | What does ra hold after that jal has run? |
| ASSEMBLER_KNOWS_HELPER | Does the assembler know the address of helper when it works on a.o? |
| LINK_WITHOUT_B | Does the link succeed if b.o is left out? |
| HELPER_FOR_A_CODE | The code of a.o becomes A_CODE bytes long. Give the address of helper, as an expression in A_CODE. |
Examples
Example 1
CODE BASE OF B- Input
At which address does the code of b.o start?
- Output
matches = 1
Directly after the 24 bytes of code of a.o.
Example 2
ADDRESS OF MAIN- Input
What is the address of main?
- Output
matches = 1
The base of the code of a.o, 0, plus the offset 0.
Example 3
ADDRESS OF HELPER- Input
What is the address of helper?
- Output
matches = 1
The base of the code of b.o, 24, plus the offset 4.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For HELPER_FOR_A_CODE, enter a constant expression using A_CODE. Only this entry changes with the parameter. The supported integer range is 24 through 200, inclusive.
Hints
Hint 1
Write down the first and the last address of each of the four sections.
Hint 2
For each symbol, add its offset to the base of its section.
Hint 3
For the jal, subtract the address of the jal from the address of its target.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
14 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 problem on this path