| ... | @@ -45,29 +45,21 @@ pub const File = union(enum) { | ... | @@ -45,29 +45,21 @@ pub const File = union(enum) { |
| 45 | | 45 | |
| 46 | /// Encodes symbol rank so that the following ordering applies: | 46 | /// Encodes symbol rank so that the following ordering applies: |
| 47 | /// * strong in object | 47 | /// * strong in object |
| 48 | /// * weak in object | | |
| 49 | /// * tentative in object | | |
| 50 | /// * strong in archive/dylib | 48 | /// * strong in archive/dylib |
| | 49 | /// * weak in object |
| 51 | /// * weak in archive/dylib | 50 | /// * weak in archive/dylib |
| | 51 | /// * tentative in object |
| 52 | /// * tentative in archive | 52 | /// * tentative in archive |
| 53 | /// * unclaimed | 53 | /// * unclaimed |
| | 54 | /// Ties are broken by file priority. |
| 54 | pub fn getSymbolRank(file: File, args: struct { | 55 | pub fn getSymbolRank(file: File, args: struct { |
| 55 | archive: bool = false, | 56 | archive: bool = false, |
| 56 | weak: bool = false, | 57 | weak: bool = false, |
| 57 | tentative: bool = false, | 58 | tentative: bool = false, |
| 58 | }) u32 { | 59 | }) u32 { |
| 59 | if (file != .dylib and !args.archive) { | 60 | const archive_or_dylib = @as(u32, @intFromBool(file == .dylib or args.archive)) << 29; |
| 60 | const base: u32 = blk: { | 61 | const strength: u32 = if (args.tentative) 0b10 << 30 else if (args.weak) 0b01 << 30 else 0b00 << 30; |
| 61 | if (args.tentative) break :blk 3; | 62 | return strength | archive_or_dylib | file.getIndex(); |
| 62 | break :blk if (args.weak) 2 else 1; | | |
| 63 | }; | | |
| 64 | return (base << 16) + file.getIndex(); | | |
| 65 | } | | |
| 66 | const base: u32 = blk: { | | |
| 67 | if (args.tentative) break :blk 3; | | |
| 68 | break :blk if (args.weak) 2 else 1; | | |
| 69 | }; | | |
| 70 | return base + (file.getIndex() << 24); | | |
| 71 | } | 63 | } |
| 72 | | 64 | |
| 73 | pub fn getAtom(file: File, atom_index: Atom.Index) ?*Atom { | 65 | pub fn getAtom(file: File, atom_index: Atom.Index) ?*Atom { |