| ... | ... | @@ -242,6 +242,17 @@ const SymbolAtIndex = struct { |
| 242 | 242 | return mem.sliceTo(@ptrCast([*:0]const u8, ctx.in_strtab.?.ptr + off), 0); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | fn getSymbolSeniority(self: SymbolAtIndex, ctx: Context) u2 { |
| 246 | const sym = self.getSymbol(ctx); |
| 247 | if (!sym.ext()) { |
| 248 | const sym_name = self.getSymbolName(ctx); |
| 249 | if (mem.startsWith(u8, sym_name, "l") or mem.startsWith(u8, sym_name, "L")) return 0; |
| 250 | return 1; |
| 251 | } |
| 252 | if (sym.weakDef() or sym.pext()) return 2; |
| 253 | return 3; |
| 254 | } |
| 255 | |
| 245 | 256 | /// Performs lexicographic-like check. |
| 246 | 257 | /// * lhs and rhs defined |
| 247 | 258 | /// * if lhs == rhs |
| ... | ... | @@ -256,23 +267,15 @@ const SymbolAtIndex = struct { |
| 256 | 267 | if (lhs.sect() and rhs.sect()) { |
| 257 | 268 | if (lhs.n_value == rhs.n_value) { |
| 258 | 269 | if (lhs.n_sect == rhs.n_sect) { |
| 259 | | if (lhs.ext() and rhs.ext()) { |
| 260 | | if ((lhs.pext() or lhs.weakDef()) and (rhs.pext() or rhs.weakDef())) { |
| 261 | | return false; |
| 262 | | } else return rhs.pext() or rhs.weakDef(); |
| 263 | | } else { |
| 264 | | const lhs_name = lhs_index.getSymbolName(ctx); |
| 265 | | const lhs_temp = mem.startsWith(u8, lhs_name, "l") or mem.startsWith(u8, lhs_name, "L"); |
| 266 | | const rhs_name = rhs_index.getSymbolName(ctx); |
| 267 | | const rhs_temp = mem.startsWith(u8, rhs_name, "l") or mem.startsWith(u8, rhs_name, "L"); |
| 268 | | if (lhs_temp and rhs_temp) { |
| 269 | | return false; |
| 270 | | } else return rhs_temp; |
| 271 | | } |
| 270 | const lhs_senior = lhs_index.getSymbolSeniority(ctx); |
| 271 | const rhs_senior = rhs_index.getSymbolSeniority(ctx); |
| 272 | if (lhs_senior == rhs_senior) { |
| 273 | return lessThanByNStrx(ctx, lhs_index, rhs_index); |
| 274 | } else return lhs_senior < rhs_senior; |
| 272 | 275 | } else return lhs.n_sect < rhs.n_sect; |
| 273 | 276 | } else return lhs.n_value < rhs.n_value; |
| 274 | 277 | } else if (lhs.undf() and rhs.undf()) { |
| 275 | | return false; |
| 278 | return lessThanByNStrx(ctx, lhs_index, rhs_index); |
| 276 | 279 | } else return rhs.undf(); |
| 277 | 280 | } |
| 278 | 281 | |
| ... | ... | @@ -786,6 +789,7 @@ fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void { |
| 786 | 789 | mem.asBytes(&record), |
| 787 | 790 | @intCast(i32, offset), |
| 788 | 791 | ); |
| 792 | log.debug("unwind record {d} tracks {s}", .{ record_id, zld.getSymbolName(target) }); |
| 789 | 793 | if (target.getFile() != object_id) { |
| 790 | 794 | self.unwind_relocs_lookup[record_id].dead = true; |
| 791 | 795 | } else { |