| ... | ... | @@ -438,6 +438,10 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype |
| 438 | 438 | error.RelocFailure => has_reloc_errors = true, |
| 439 | 439 | else => |e| return e, |
| 440 | 440 | }, |
| 441 | .aarch64 => aarch64.scanReloc(self, elf_file, rel, symbol, code, &it) catch |err| switch (err) { |
| 442 | error.RelocFailure => has_reloc_errors = true, |
| 443 | else => |e| return e, |
| 444 | }, |
| 441 | 445 | else => return error.UnsupportedCpuArch, |
| 442 | 446 | } |
| 443 | 447 | } |
| ... | ... | @@ -1549,6 +1553,61 @@ const x86_64 = struct { |
| 1549 | 1553 | const Instruction = encoder.Instruction; |
| 1550 | 1554 | }; |
| 1551 | 1555 | |
| 1556 | const aarch64 = struct { |
| 1557 | fn scanReloc( |
| 1558 | atom: Atom, |
| 1559 | elf_file: *Elf, |
| 1560 | rel: elf.Elf64_Rela, |
| 1561 | symbol: *Symbol, |
| 1562 | code: ?[]const u8, |
| 1563 | it: *RelocsIterator, |
| 1564 | ) !void { |
| 1565 | _ = code; |
| 1566 | _ = it; |
| 1567 | |
| 1568 | const r_type: elf.R_AARCH64 = @enumFromInt(rel.r_type()); |
| 1569 | switch (r_type) { |
| 1570 | .ABS64 => { |
| 1571 | try atom.scanReloc(symbol, rel, dynAbsRelocAction(symbol, elf_file), elf_file); |
| 1572 | }, |
| 1573 | |
| 1574 | .ADR_PREL_PG_HI21 => { |
| 1575 | try atom.scanReloc(symbol, rel, pcRelocAction(symbol, elf_file), elf_file); |
| 1576 | }, |
| 1577 | |
| 1578 | .ADR_GOT_PAGE => { |
| 1579 | // TODO: relax if possible |
| 1580 | symbol.flags.needs_got = true; |
| 1581 | }, |
| 1582 | |
| 1583 | .LD64_GOT_LO12_NC, |
| 1584 | .LD64_GOTPAGE_LO15, |
| 1585 | => { |
| 1586 | symbol.flags.needs_got = true; |
| 1587 | }, |
| 1588 | |
| 1589 | .CALL26, |
| 1590 | .JUMP26, |
| 1591 | => { |
| 1592 | if (symbol.flags.import) { |
| 1593 | symbol.flags.needs_plt = true; |
| 1594 | } |
| 1595 | }, |
| 1596 | |
| 1597 | .ADD_ABS_LO12_NC, |
| 1598 | .ADR_PREL_LO21, |
| 1599 | .LDST8_ABS_LO12_NC, |
| 1600 | .LDST16_ABS_LO12_NC, |
| 1601 | .LDST32_ABS_LO12_NC, |
| 1602 | .LDST64_ABS_LO12_NC, |
| 1603 | .LDST128_ABS_LO12_NC, |
| 1604 | => {}, |
| 1605 | |
| 1606 | else => try atom.reportUnhandledRelocError(rel, elf_file), |
| 1607 | } |
| 1608 | } |
| 1609 | }; |
| 1610 | |
| 1552 | 1611 | const ResolveArgs = struct { i64, i64, i64, i64, i64, i64, i64, i64 }; |
| 1553 | 1612 | |
| 1554 | 1613 | const RelocError = error{ |