| ... | @@ -242,6 +242,17 @@ const SymbolAtIndex = struct { | ... | @@ -242,6 +242,17 @@ const SymbolAtIndex = struct { |
| 242 | return mem.sliceTo(@ptrCast([*:0]const u8, ctx.in_strtab.?.ptr + off), 0); | 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 | /// Performs lexicographic-like check. | 256 | /// Performs lexicographic-like check. |
| 246 | /// * lhs and rhs defined | 257 | /// * lhs and rhs defined |
| 247 | /// * if lhs == rhs | 258 | /// * if lhs == rhs |
| ... | @@ -256,23 +267,15 @@ const SymbolAtIndex = struct { | ... | @@ -256,23 +267,15 @@ const SymbolAtIndex = struct { |
| 256 | if (lhs.sect() and rhs.sect()) { | 267 | if (lhs.sect() and rhs.sect()) { |
| 257 | if (lhs.n_value == rhs.n_value) { | 268 | if (lhs.n_value == rhs.n_value) { |
| 258 | if (lhs.n_sect == rhs.n_sect) { | 269 | if (lhs.n_sect == rhs.n_sect) { |
| 259 | if (lhs.ext() and rhs.ext()) { | 270 | const lhs_senior = lhs_index.getSymbolSeniority(ctx); |
| 260 | if ((lhs.pext() or lhs.weakDef()) and (rhs.pext() or rhs.weakDef())) { | 271 | const rhs_senior = rhs_index.getSymbolSeniority(ctx); |
| 261 | return false; | 272 | if (lhs_senior == rhs_senior) { |
| 262 | } else return rhs.pext() or rhs.weakDef(); | 273 | return lessThanByNStrx(ctx, lhs_index, rhs_index); |
| 263 | } else { | 274 | } else return lhs_senior < rhs_senior; |
| 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 | } | | |
| 272 | } else return lhs.n_sect < rhs.n_sect; | 275 | } else return lhs.n_sect < rhs.n_sect; |
| 273 | } else return lhs.n_value < rhs.n_value; | 276 | } else return lhs.n_value < rhs.n_value; |
| 274 | } else if (lhs.undf() and rhs.undf()) { | 277 | } else if (lhs.undf() and rhs.undf()) { |
| 275 | return false; | 278 | return lessThanByNStrx(ctx, lhs_index, rhs_index); |
| 276 | } else return rhs.undf(); | 279 | } else return rhs.undf(); |
| 277 | } | 280 | } |
| 278 | | 281 | |
| ... | @@ -786,6 +789,7 @@ fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void { | ... | @@ -786,6 +789,7 @@ fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void { |
| 786 | mem.asBytes(&record), | 789 | mem.asBytes(&record), |
| 787 | @intCast(i32, offset), | 790 | @intCast(i32, offset), |
| 788 | ); | 791 | ); |
| | 792 | log.debug("unwind record {d} tracks {s}", .{ record_id, zld.getSymbolName(target) }); |
| 789 | if (target.getFile() != object_id) { | 793 | if (target.getFile() != object_id) { |
| 790 | self.unwind_relocs_lookup[record_id].dead = true; | 794 | self.unwind_relocs_lookup[record_id].dead = true; |
| 791 | } else { | 795 | } else { |