| ... | @@ -668,6 +668,25 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye | ... | @@ -668,6 +668,25 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 668 | | 668 | |
| 669 | try stubs_writer.writeAll(".data\n"); | 669 | try stubs_writer.writeAll(".data\n"); |
| 670 | | 670 | |
| | 671 | // FreeBSD's `libc.so.7` contains strong references to `__progname` and `environ` which are |
| | 672 | // defined in the statically-linked startup code. Those references cause the linker to put |
| | 673 | // the symbols in the dynamic symbol table. We need to create dummy references to them here |
| | 674 | // to get the same effect. |
| | 675 | if (std.mem.eql(u8, lib.name, "c")) { |
| | 676 | try stubs_writer.print( |
| | 677 | \\.balign {d} |
| | 678 | \\.globl __progname |
| | 679 | \\.globl environ |
| | 680 | \\{s} __progname |
| | 681 | \\{s} environ |
| | 682 | \\ |
| | 683 | , .{ |
| | 684 | target.ptrBitWidth() / 8, |
| | 685 | wordDirective(target), |
| | 686 | wordDirective(target), |
| | 687 | }); |
| | 688 | } |
| | 689 | |
| 671 | const obj_inclusions_len = try inc_reader.readInt(u16, .little); | 690 | const obj_inclusions_len = try inc_reader.readInt(u16, .little); |
| 672 | | 691 | |
| 673 | var sizes = try arena.alloc(u16, metadata.all_versions.len); | 692 | var sizes = try arena.alloc(u16, metadata.all_versions.len); |