Which archive members enter the link?

A C project links ordinary object files with a static archive, a collection of object files from which the linker can extract individual members. Use this linker model:

  • Process inputs from left to right. Always include an ordinary object file, recording its definitions and unresolved references.
  • When an archive is reached, extract a member if it defines a currently unresolved symbol. Record that member's definitions and references, then continue searching the same archive until no further member is needed.
  • Do not revisit an archive after moving to the next input.

The available files contain the following symbols. All symbols are distinct, and no other inputs define or reference them.


File or archive member

Defines

References

main.o

main

read_samples, report

report.o

report

none

libmeter.a member read.o

read_samples

scale

libmeter.a member scale.o

scale

none

libmeter.a member diagnostics.o

diagnostics

none


Compare these two input orders:


Plain text
main.o libmeter.a report.o
libmeter.a main.o report.o


For each order, enter the exact integer number of archive members extracted and the exact integer number of distinct symbols still unresolved after all inputs have been processed. Count archive members only in the first answer column.

Input orderArchive members extractedUnresolved symbols at end
main.o libmeter.a report.o
libmeter.a main.o report.o

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Compiling and the Build Process Questions: