lib/tldr/src/formats/elf/diagnostic.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 const root = @import("../../root.zig");
 2 const format = @import("format.zig");
 3 const parser = @import("parser.zig");
 4 
 5 const model = root.model;
 6 const ObjectFile = parser.ObjectFile;
 7 const Rela = format.Rela;
 8 const Symbol = format.Symbol;
 9 
10 pub fn recordUndefinedSymbol(
11     options: model.LinkOptions,
12     object: ObjectFile,
13     symbol: Symbol,
14 ) void {
15     if (options.diagnostics) |diagnostics| {
16         diagnostics.recordUndefinedSymbol(object.name, symbol.name);
17     }
18 }
19 
20 pub fn recordUnsupportedRelocation(
21     options: model.LinkOptions,
22     object: ObjectFile,
23     section_index: usize,
24     relocation: Rela,
25 ) void {
26     if (options.diagnostics) |diagnostics| {
27         const section_name = if (section_index < object.sections.len)
28             parser.sectionNameOrEmpty(object, section_index)
29         else
30             "";
31         const symbol_name = if (relocation.symbolIndex() < object.symbols.len)
32             object.symbols[@intCast(relocation.symbolIndex())].name
33         else
34             "";
35         diagnostics.recordUnsupportedRelocation(
36             object.name,
37             section_name,
38             symbol_name,
39             relocation.relocationType(),
40         );
41     }
42 }