[RFC] code changes/removal in boot2.c and ufsread.c so clang
can compile boot2
Alexander Best
arundel at freebsd.org
Tue Feb 22 19:23:13 UTC 2011
On Tue Feb 22 11, Roman Divacky wrote:
> fwiw, this is what I have:
>
> http://lev.vlakno.cz/~rdivacky/boot2-diet.patch
>
> with some llvm changed (-mrtd implementation + earlycse at the
> end of -O2) I am still at -113 bytes short on UFS1+UFS2 boot2
i was wondering...could we get rid of all the PATH_CONFIG and PATH_KERNEL
stuff? i tried this the other day with gptboot (which is pretty much
identical to boot2) and it seems booting a kernel directly got broken a long
time ago. so since invoking the loader is mandatory we could dump the kernel
loading code and the code that looks for entries in /boot.config completely.
you should be able to verify this by hitting a key before boot2 comes up and
enter the path to your kernel directly. for me it failed loading the kernel
(that's on amd64) with some btx error.
cheers.
alex
>
> this is with latest llvm, with the one in fbsd it was at roughly -80
> (stack alignment changes)
>
> On Tue, Feb 22, 2011 at 06:30:16PM +0000, Alexander Best wrote:
> > On Tue Feb 22 11, Warner Losh wrote:
> > > On 02/18/2011 18:01, Alexander Best wrote:
> > > >hi everybody,
> > > >
> > > >r218745 triggered quite a discussion about dead code in boot2.c. i talked
> > > >to
> > > >roman (rdivacky@) and we were trying to improve the situation so that boot2
> > > >would build with clang 2.8 (base) and the latest development version of
> > > >clang (trunk). a lot of the ideas came from Bruce (bde@).
> > > >
> > > >i'd really appreciate, if somebody could have a look at this patchset. for
> > > >me
> > > >it strips down the boot2 code so clang is able to compile it just fine.
> > > >please
> > > >bear in mind that this has to work with boot2 supporting UFS1 *and* UFS2.
> > > >so
> > > >please be sure not to override BOOT2_UFS in your src.conf or some place
> > > >else.
> > > >
> > > >you should be able to test the (hopefully sucessfully) compiled boot2
> > > >binary
> > > >by copying it to /boot. please be sure to keep a backup of your existing
> > > >boot2
> > > >file in case something breaks.
> > > >
> > > >the patchset (against a recent HEAD) can be found here:
> > > >http://people.freebsd.org/~arundel/patches/boot2.c.diff2
> > > >
> > > >cheers.
> > > >alex
> > > >
> > >
> > > Here's some comments:
> > >
> > > @@ -88,7 +97,7 @@ static ino_t lookup(const char *);
> > > static ssize_t fsread(ino_t, void *, size_t);
> > >
> > > static int ls, dsk_meta;
> > > -static uint32_t fs_off;
> > > +static uint32_t fs_off = 0;
> > >
> > > static __inline int
> > > fsfind(const char *name, ino_t * ino)
> > > @@ -98,7 +107,6 @@ fsfind(const char *name, ino_t * ino)
> > > char *s;
> > > ssize_t n;
> > >
> > > - fs_off = 0;
> > > while ((n = fsread(*ino, buf, DEV_BSIZE))> 0)
> > > for (s = buf; s< buf + DEV_BSIZE;) {
> > > d = (void *)s;
> > >
> > > How does the first part of this diff change things? bss gets the
> > > uninitialized and the data initialized to 0.
> > >
> > > but we also have this later:
> > >
> > > @@ -238,7 +245,6 @@ fsread(ino_t inode, void *buf, size_t nbyte)
> > >
> > > #endif
> > > inomap = inode;
> > > - fs_off = 0;
> > > blkmap = indmap = 0;
> > > }
> > > s = buf;
> > >
> > >
> > > - if (N_GETMAGIC(hdr.ex) == ZMAGIC)
> > > - fmt = 0;
> > > - else if (IS_ELF(hdr.eh))
> > > + if (IS_ELF(eh))
> > > fmt = 1;
> > >
> > >
> > > Doesn't this remove a.out support?
> >
> > indeed i removed that part from the newest patch:
> >
> > http://people.freebsd.org/~arundel/patches/boot2.c.diff3
> >
> > >
> > > Warner
> >
> > --
> > a13x
> > _______________________________________________
> > freebsd-toolchain at freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> > To unsubscribe, send any mail to "freebsd-toolchain-unsubscribe at freebsd.org"
--
a13x
More information about the freebsd-toolchain
mailing list