diff options
| author | Rob Arnold <[email protected]> | 2011-02-05 01:09:35 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-02-09 11:37:20 -0800 |
| commit | a1cc5ac63c7d2b7da595cbc31253389a991824bd (patch) | |
| tree | c41fc35812483fd062e2b3c6f58d5c93c863a425 /src/boot/be | |
| parent | Add FreeBSD_x86_elf target to rustboot (diff) | |
| download | rust-a1cc5ac63c7d2b7da595cbc31253389a991824bd.tar.xz rust-a1cc5ac63c7d2b7da595cbc31253389a991824bd.zip | |
Adapt elf.ml to handle differences between Linux and FreeBSD.
Diffstat (limited to 'src/boot/be')
| -rw-r--r-- | src/boot/be/elf.ml | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/boot/be/elf.ml b/src/boot/be/elf.ml index 406508e4..a1706082 100644 --- a/src/boot/be/elf.ml +++ b/src/boot/be/elf.ml @@ -44,7 +44,7 @@ type ei_data = ;; -let elf_identification ei_class ei_data = +let elf_identification sess ei_class ei_data = SEQ [| STRING "\x7fELF"; @@ -58,9 +58,17 @@ let elf_identification ei_class ei_data = ELFDATANONE -> 0 | ELFDATA2LSB -> 1 | ELFDATA2MSB -> 2); + 1; (* EI_VERSION = EV_CURRENT *) - 0; (* EI_PAD #7 *) - 0; (* EI_PAD #8 *) + + (* EI_OSABI *) + (match sess.Session.sess_targ with + FreeBSD_x86_elf -> 9 + | Linux_x86_elf -> 3 + | _ -> 0); + + 0; (* EI_ABIVERSION *) + 0; (* EI_PAD #9 *) 0; (* EI_PAD #A *) 0; (* EI_PAD #B *) @@ -117,7 +125,7 @@ let elf32_header in DEF (elf_header_fixup, - SEQ [| elf_identification ELFCLASS32 ei_data; + SEQ [| elf_identification sess ELFCLASS32 ei_data; WORD (TY_u16, (IMM (match e_type with ET_NONE -> 0L | ET_REL -> 1L @@ -1290,7 +1298,11 @@ let elf32_linux_x86_file in let interp_section = - DEF (interp_section_fixup, ZSTRING "/lib/ld-linux.so.2") + + DEF (interp_section_fixup, ZSTRING + (if sess.Session.sess_targ = FreeBSD_x86_elf + then "/libexec/ld-elf.so.1" + else "/lib/ld-linux.so.2")) in let text_section = @@ -1584,7 +1596,9 @@ let emit_file let needed_libs = [| - "libc.so.6"; + if sess.Session.sess_targ = FreeBSD_x86_elf + then "libc.so.7" + else "libc.so.6"; "librustrt.so" |] in |