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