mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 18:30:28 +00:00
sysv2freebsd error handling
This commit is contained in:
parent
5588cf643a
commit
bc193cac9f
1 changed files with 15 additions and 2 deletions
|
@ -20,12 +20,25 @@
|
||||||
#include "libc/elf/def.h"
|
#include "libc/elf/def.h"
|
||||||
#include "libc/elf/struct/ehdr.h"
|
#include "libc/elf/struct/ehdr.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/sysv/consts/map.h"
|
#include "libc/sysv/consts/map.h"
|
||||||
#include "libc/sysv/consts/o.h"
|
#include "libc/sysv/consts/o.h"
|
||||||
#include "libc/sysv/consts/prot.h"
|
#include "libc/sysv/consts/prot.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
open(argv[1], O_RDWR);
|
int fd;
|
||||||
Elf64_Ehdr *e = mmap(0, 64, PROT_READ | PROT_WRITE, MAP_SHARED, 3, 0);
|
Elf64_Ehdr *e;
|
||||||
e->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "usage: %s <file>\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
} else if ((fd = open(argv[1], O_RDWR)) < 0) {
|
||||||
|
perror("open");
|
||||||
|
exit(1);
|
||||||
|
} else if ((e = mmap(0, 64, PROT_READ | PROT_WRITE, MAP_SHARED, 3, 0)) ==
|
||||||
|
MAP_FAILED) {
|
||||||
|
perror("mmap");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
e->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue