summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2000-01-04 14:10:36 +0000
committermarcel <marcel@FreeBSD.org>2000-01-04 14:10:36 +0000
commit71adbdbe1afd64efe13457f38b20baa8dd9758e0 (patch)
tree47dd552dcb36bf6432f61110a1657f7e00c3ef82 /usr.sbin
parent3428629295a631b7efb9f963a5747ded4524f288 (diff)
downloadFreeBSD-src-71adbdbe1afd64efe13457f38b20baa8dd9758e0.zip
FreeBSD-src-71adbdbe1afd64efe13457f38b20baa8dd9758e0.tar.gz
o Allow btxld to be compiled on 64-bit machines
o s/unsigned/unsigned int/g o Add -Wall btxld can now be built as a cross-tool for cross-building i386/pc98 on platforms that don't have btxld (such as alpha).
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/btxld/Makefile2
-rw-r--r--usr.sbin/btxld/btxld.c34
-rw-r--r--usr.sbin/btxld/elfh.c2
-rw-r--r--usr.sbin/btxld/elfh.h4
4 files changed, 24 insertions, 18 deletions
diff --git a/usr.sbin/btxld/Makefile b/usr.sbin/btxld/Makefile
index 229b20e..6775183 100644
--- a/usr.sbin/btxld/Makefile
+++ b/usr.sbin/btxld/Makefile
@@ -4,4 +4,6 @@ PROG= btxld
SRCS= btxld.c elfh.c
MAN8= btxld.8
+CFLAGS+= -Wall
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/btxld/btxld.c b/usr.sbin/btxld/btxld.c
index e24f4f4..9e83beb 100644
--- a/usr.sbin/btxld/btxld.c
+++ b/usr.sbin/btxld/btxld.c
@@ -43,7 +43,6 @@ static const char rcsid[] =
#include <unistd.h>
#include <a.out.h>
-#include <elf.h>
#include "btx.h"
#include "elfh.h"
@@ -65,14 +64,14 @@ static const char rcsid[] =
#define align(x, y) (((x) + (y) - 1) & ~((y) - 1))
struct hdr {
- unsigned fmt; /* Format */
- unsigned flags; /* Bit flags */
- unsigned size; /* Size of file */
- unsigned text; /* Size of text segment */
- unsigned data; /* Size of data segment */
- unsigned bss; /* Size of bss segment */
- unsigned org; /* Program origin */
- unsigned entry; /* Program entry point */
+ uint32_t fmt; /* Format */
+ uint32_t flags; /* Bit flags */
+ uint32_t size; /* Size of file */
+ uint32_t text; /* Size of text segment */
+ uint32_t data; /* Size of data segment */
+ uint32_t bss; /* Size of bss segment */
+ uint32_t org; /* Program origin */
+ uint32_t entry; /* Program entry point */
};
static const char *const fmtlist[] = {"bin", "aout", "elf"};
@@ -95,7 +94,7 @@ static const char *oname =
static int ppage = -1; /* First page present */
static int wpage = -1; /* First page writable */
-static unsigned format; /* Output format */
+static unsigned int format; /* Output format */
static uint32_t centry; /* Client entry address */
static uint32_t lentry; /* Loader entry address */
@@ -117,7 +116,7 @@ static void copy(int, int, size_t, off_t);
static size_t readx(int, void *, size_t, off_t);
static void writex(int, const void *, size_t);
static void seekx(int, off_t);
-static unsigned optfmt(const char *);
+static unsigned int optfmt(const char *);
static uint32_t optaddr(const char *);
static int optpage(const char *, int);
static void Warn(const char *, const char *, ...);
@@ -195,9 +194,11 @@ btxld(const char *iname)
char name[FILENAME_MAX];
struct btx_hdr btx;
struct hdr ihdr, ohdr;
- unsigned ldr_size, cwr;
+ unsigned int ldr_size, cwr;
int fdi[3], fdo, i;
+ ldr_size = 0;
+
for (i = I_LDR; i <= I_CLNT; i++) {
fname = i == I_LDR ? lname : i == I_BTX ? bname : iname;
if ((fdi[i] = open(fname, O_RDONLY)) == -1)
@@ -228,7 +229,7 @@ btxld(const char *iname)
ohdr.org = lentry;
ohdr.entry = lentry;
cwr = 0;
- if (wpage > 0 || (wpage == -1 && !(ihdr.flags & IMPURE)))
+ if (wpage > 0 || (wpage == -1 && !(ihdr.flags & IMPURE))) {
if (wpage > 0)
cwr = wpage;
else {
@@ -236,6 +237,7 @@ btxld(const char *iname)
if (cwr > BTX_MAXCWR)
cwr = BTX_MAXCWR;
}
+ }
if (ppage > 0 || (ppage && wpage && ihdr.org >= BTX_PGSIZE)) {
btx.btx_flags |= BTX_MAPONE;
if (!cwr)
@@ -312,7 +314,7 @@ gethdr(int fd, struct hdr *hdr)
const Elf32_Ehdr *ee;
const Elf32_Phdr *ep;
void *p;
- unsigned fmt, x, n, i;
+ unsigned int fmt, x, n, i;
memset(hdr, 0, sizeof(*hdr));
if (fstat(fd, &sb))
@@ -480,10 +482,10 @@ seekx(int fd, off_t offset)
/*
* Convert an option argument to a format code.
*/
-static unsigned
+static unsigned int
optfmt(const char *arg)
{
- unsigned i;
+ unsigned int i;
for (i = 0; i < F_CNT && strcmp(arg, fmtlist[i]); i++);
if (i == F_CNT)
diff --git a/usr.sbin/btxld/elfh.c b/usr.sbin/btxld/elfh.c
index cf16348..0f0928b 100644
--- a/usr.sbin/btxld/elfh.c
+++ b/usr.sbin/btxld/elfh.c
@@ -26,6 +26,8 @@
* $FreeBSD$
*/
+#include <sys/types.h>
+
#include <stddef.h>
#include "elfh.h"
diff --git a/usr.sbin/btxld/elfh.h b/usr.sbin/btxld/elfh.h
index cf00f38..a4ab134 100644
--- a/usr.sbin/btxld/elfh.h
+++ b/usr.sbin/btxld/elfh.h
@@ -26,7 +26,7 @@
* $FreeBSD$
*/
-#include <elf.h>
+#include <sys/elf32.h>
struct elfh {
Elf32_Ehdr e; /* ELF header */
@@ -35,4 +35,4 @@ struct elfh {
char shstrtab[28]; /* section header string table */
};
-const struct elfh elfhdr; /* ELF header template */
+extern const struct elfh elfhdr; /* ELF header template */
OpenPOWER on IntegriCloud