Bug#1059870: aboot: Please help testing dropping a.out.h support

2024-01-02 Thread Dimitri John Ledkov
On Tue, 2 Jan 2024 at 21:00, John Paul Adrian Glaubitz
 wrote:
>
> On Tue, 2024-01-02 at 18:07 +, Dimitri John Ledkov wrote:
> > For cross building, as far as I can tell one needs to build the tool
> > twice - once for the BUILD architecture and once for HOST
> > architecture, use one during the build and package the other one into
> > the deb.
>
> That's correct and I am currently pondering over a clever way to do that.
>
> > > I will most likely just copy the relevant definitions out of aout.h, both
> > > the generic and the alpha-specific stuff in order to both be able to drop
> > > reliance on aout.h in the kernel as well as make the package fully cross-
> > > buildable.
> >
> > But why? as far as I can tell, the a.out code path is never executed
> > as it seems like Debian has been using ELF based vmlinuz since like
> > before 2009. Are you sure that the a.out codepath of objstrip.c is
> > needed or executed at all?
> >
> > Or am I missing something, and like objstrip.c portions are executed
> > against some other a.out formatted things which are not Linux kernel?
> >
> > Should I provide a patch that adds printfs during a.out codepath
> > block, to see if it actually is ever executed?
>
> I think it's still reasonable to keep a.out support in the tool because
> users might use it for a.out binaries generated from other tools.

Which tools? given that support has been dropped to execute any
binaries like that everywhere. This still sounds very hypothetical,
given that code path is specifically for vmlinux kernel only.

> Besides,
> it's just a matter of copying a few header definitions, so not really a
> blocker unless I am missing something.
>
> > >
> > > I would also prefer to get all relevant changes upstreamed.
> > >
> >
> > Upstream has policy of not carrying dead code, which in this case its
> > what it is for kernels built in like last decade.
>
> I was talking about aboot upstream which is maintained by Matt Turner from
> Gentoo these days [1].

Ok, and I'm talking about linux kernel copy of aboot at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/alpha/boot

Can you please test the debdiff I have attached, such that I can
confirm with linux kernel upstream that I can drop a.out.h support
there?

I do not have access to alpha, and currently this is the remaining
piece holding up a.out.h in linux kernel upstream on x86 alpha m86k
mips. Which would be nice to drop.

>
> Adrian
>
> > [1] https://github.com/mattst88/aboot/
>
> --
>  .''`.  John Paul Adrian Glaubitz
> : :' :  Debian Developer
> `. `'   Physicist
>   `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



-- 
Dimitri

Sent from Ubuntu Pro
https://ubuntu.com/pro



Bug#1059870: aboot: Please help testing dropping a.out.h support

2024-01-02 Thread John Paul Adrian Glaubitz
On Tue, 2024-01-02 at 18:07 +, Dimitri John Ledkov wrote:
> For cross building, as far as I can tell one needs to build the tool
> twice - once for the BUILD architecture and once for HOST
> architecture, use one during the build and package the other one into
> the deb.

That's correct and I am currently pondering over a clever way to do that.

> > I will most likely just copy the relevant definitions out of aout.h, both
> > the generic and the alpha-specific stuff in order to both be able to drop
> > reliance on aout.h in the kernel as well as make the package fully cross-
> > buildable.
> 
> But why? as far as I can tell, the a.out code path is never executed
> as it seems like Debian has been using ELF based vmlinuz since like
> before 2009. Are you sure that the a.out codepath of objstrip.c is
> needed or executed at all?
> 
> Or am I missing something, and like objstrip.c portions are executed
> against some other a.out formatted things which are not Linux kernel?
> 
> Should I provide a patch that adds printfs during a.out codepath
> block, to see if it actually is ever executed?

I think it's still reasonable to keep a.out support in the tool because
users might use it for a.out binaries generated from other tools. Besides,
it's just a matter of copying a few header definitions, so not really a
blocker unless I am missing something.

> > 
> > I would also prefer to get all relevant changes upstreamed.
> > 
> 
> Upstream has policy of not carrying dead code, which in this case its
> what it is for kernels built in like last decade.

I was talking about aboot upstream which is maintained by Matt Turner from
Gentoo these days [1].

Adrian

> [1] https://github.com/mattst88/aboot/

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Bug#1059870: aboot: Please help testing dropping a.out.h support

2024-01-02 Thread Dimitri John Ledkov
On Tue, 2 Jan 2024 at 17:48, John Paul Adrian Glaubitz
 wrote:
>
> Hi Dimitri!
>
> On Tue, 2024-01-02 at 17:37 +, Dimitri John Ledkov wrote:
> > a.out support has been dropped in upstream kernel. However a.out.h
> > header is still being using by abootimg tool via objstrip.c. It has
> > support for both a.out image types and ELF. I have blidly dropped
> > a.out.h support and made ELF support mandatory in
> > https://lore.kernel.org/all/20231123180246.750674-2-dimitri.led...@canonical.com/
> > but I have no way to build it for alpha or test if everything still
> > works. Upgrades, installed systems, and cd-boot.
> >
> > Could you please consider the attached NMU, build it and test it, and
> > let me know if everything still works. Cause then a.out.h header can
> > be removed from upstream linux kernel on all architectures.
>
> I have actually already looked into patching aboot myself to deal with the
> aout.h issue since I want to make the bootloader fully cross-buildable [1].
>

For cross building, as far as I can tell one needs to build the tool
twice - once for the BUILD architecture and once for HOST
architecture, use one during the build and package the other one into
the deb.


> I will most likely just copy the relevant definitions out of aout.h, both
> the generic and the alpha-specific stuff in order to both be able to drop
> reliance on aout.h in the kernel as well as make the package fully cross-
> buildable.

But why? as far as I can tell, the a.out code path is never executed
as it seems like Debian has been using ELF based vmlinuz since like
before 2009. Are you sure that the a.out codepath of objstrip.c is
needed or executed at all?

Or am I missing something, and like objstrip.c portions are executed
against some other a.out formatted things which are not Linux kernel?

Should I provide a patch that adds printfs during a.out codepath
block, to see if it actually is ever executed?

>
> I would also prefer to get all relevant changes upstreamed.
>

Upstream has policy of not carrying dead code, which in this case its
what it is for kernels built in like last decade.


> Thanks,
> Adrian
>
> > [1] https://github.com/mattst88/aboot/issues/5
>
> --
>  .''`.  John Paul Adrian Glaubitz
> : :' :  Debian Developer
> `. `'   Physicist
>   `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



--
Dimitri

Sent from Ubuntu Pro
https://ubuntu.com/pro



Bug#1059870: aboot: Please help testing dropping a.out.h support

2024-01-02 Thread John Paul Adrian Glaubitz
Hi Dimitri!

On Tue, 2024-01-02 at 17:37 +, Dimitri John Ledkov wrote:
> a.out support has been dropped in upstream kernel. However a.out.h
> header is still being using by abootimg tool via objstrip.c. It has
> support for both a.out image types and ELF. I have blidly dropped
> a.out.h support and made ELF support mandatory in
> https://lore.kernel.org/all/20231123180246.750674-2-dimitri.led...@canonical.com/
> but I have no way to build it for alpha or test if everything still
> works. Upgrades, installed systems, and cd-boot.
> 
> Could you please consider the attached NMU, build it and test it, and
> let me know if everything still works. Cause then a.out.h header can
> be removed from upstream linux kernel on all architectures.

I have actually already looked into patching aboot myself to deal with the
aout.h issue since I want to make the bootloader fully cross-buildable [1].

I will most likely just copy the relevant definitions out of aout.h, both
the generic and the alpha-specific stuff in order to both be able to drop
reliance on aout.h in the kernel as well as make the package fully cross-
buildable.

I would also prefer to get all relevant changes upstreamed.

Thanks,
Adrian

> [1] https://github.com/mattst88/aboot/issues/5

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Bug#1059870: aboot: Please help testing dropping a.out.h support

2024-01-02 Thread Dimitri John Ledkov
Package: aboot
Version: 1.0~pre20200212-1
Severity: important

Dear Maintainer,

a.out support has been dropped in upstream kernel. However a.out.h
header is still being using by abootimg tool via objstrip.c. It has
support for both a.out image types and ELF. I have blidly dropped
a.out.h support and made ELF support mandatory in
https://lore.kernel.org/all/20231123180246.750674-2-dimitri.led...@canonical.com/
but I have no way to build it for alpha or test if everything still
works. Upgrades, installed systems, and cd-boot.

Could you please consider the attached NMU, build it and test it, and
let me know if everything still works. Cause then a.out.h header can
be removed from upstream linux kernel on all architectures.

Regards,

Dimitri.
diff -Nru aboot-1.0~pre20200212/debian/changelog 
aboot-1.0~pre20200212/debian/changelog
--- aboot-1.0~pre20200212/debian/changelog  2020-03-07 11:12:47.0 
+
+++ aboot-1.0~pre20200212/debian/changelog  2024-01-02 17:25:40.0 
+
@@ -1,3 +1,11 @@
+aboot (1.0~pre20200212-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Drop a.out support from objstrip, and require ELF format. As a.out
+support is long dead in upstream linux.
+
+ -- Dimitri John Ledkov   Tue, 02 Jan 2024 
17:25:40 +
+
 aboot (1.0~pre20200212-1) unstable; urgency=medium
 
   * New upstream version
diff -Nru aboot-1.0~pre20200212/debian/patches/drop-a.out.patch 
aboot-1.0~pre20200212/debian/patches/drop-a.out.patch
--- aboot-1.0~pre20200212/debian/patches/drop-a.out.patch   1970-01-01 
01:00:00.0 +0100
+++ aboot-1.0~pre20200212/debian/patches/drop-a.out.patch   2024-01-02 
17:24:24.0 +
@@ -0,0 +1,96 @@
+Subject: [PATCH 1/5] alpha: remove a.out support from tools/objstrip
+Link: 
https://lore.kernel.org/all/20231123180246.750674-2-dimitri.led...@canonical.com/
+
+As a.out support has been dropped from alpha port, drop a.out support
+and make ELF support required.
+
+Only performed a test build on x86 for native x86 and cross-compiled
+for alpha.
+
+Index: aboot-1.0~pre20200212/tools/objstrip.c
+===
+--- aboot-1.0~pre20200212.orig/tools/objstrip.c
 aboot-1.0~pre20200212/tools/objstrip.c
+@@ -20,17 +20,12 @@
+ 
+ #include 
+ #include 
+-#include 
+ 
+-#include 
+-#include 
+-#include 
+-#ifdef __ELF__
+-# include 
+-# define elfhdr elf64_hdr
+-# define elf_phdr elf64_phdr
+-# define elf_check_arch(x) ((x)->e_machine == EM_ALPHA)
+-#endif
++#include 
++#define elfhdr elf64_hdr
++#define elf_phdr elf64_phdr
++#define elf_check_arch(x) ((x)->e_machine == EM_ALPHA)
++
+ 
+ /* bootfile size must be multiple of BLOCK_SIZE: */
+ #define BLOCK_SIZE512
+@@ -54,13 +49,10 @@ main (int argc, char *argv[])
+ size_t nwritten, tocopy, n, mem_size, fil_size, pad = 0;
+ int fd, ofd, i, j, verbose = 0, primary = 0;
+ char buf[8192], *inname;
+-struct exec * aout;   /* includes file & aout header */
+ long offset;
+-#ifdef __ELF__
+ struct elfhdr *elf;
+ struct elf_phdr *elf_phdr;/* program header */
+ unsigned long long e_entry;
+-#endif
+ 
+ prog_name = argv[0];
+ 
+@@ -144,7 +136,6 @@ main (int argc, char *argv[])
+   exit(1);
+ }
+ 
+-#ifdef __ELF__
+ elf = (struct elfhdr *) buf;
+ 
+ if (elf->e_ident[0] == 0x7f && strncmp((char *)elf->e_ident + 1, "ELF", 
3) == 0) {
+@@ -191,37 +182,6 @@ main (int argc, char *argv[])
+   prog_name, (long) elf_phdr->p_vaddr,
+   elf_phdr->p_vaddr + fil_size, offset);
+   }
+-} else
+-#endif
+-{
+-  aout = (struct exec *) buf;
+-
+-  if (!(aout->fh.f_flags & COFF_F_EXEC)) {
+-  fprintf(stderr, "%s: %s is not in executable format\n",
+-  prog_name, inname);
+-  exit(1);
+-  }
+-
+-  if (aout->fh.f_opthdr != sizeof(aout->ah)) {
+-  fprintf(stderr, "%s: %s has unexpected optional header size\n",
+-  prog_name, inname);
+-  exit(1);
+-  }
+-
+-  if (N_MAGIC(*aout) != OMAGIC) {
+-  fprintf(stderr, "%s: %s is not an OMAGIC file\n",
+-  prog_name, inname);
+-  exit(1);
+-  }
+-  offset = N_TXTOFF(*aout);
+-  fil_size = aout->ah.tsize + aout->ah.dsize;
+-  mem_size = fil_size + aout->ah.bsize;
+-
+-  if (verbose) {
+-  fprintf(stderr, "%s: extracting %#016lx-%#016lx (at %lx)\n",
+-  prog_name, aout->ah.text_start,
+-  aout->ah.text_start + fil_size, offset);
+-  }
+ }
+ 
+ if (lseek(fd, offset, SEEK_SET) != offset) {
diff -Nru aboot-1.0~pre20200212/debian/patches/series 
aboot-1.0~pre20200212/debian/patches/series
--- aboot-1.0~pre20200212/debian/patches/series 1970-01-01 01:00:00.0 
+0100
+++ aboot-1.0~pre20200212/debian/patches/series 2024-01-02 17:22:53.0 
+
@@ -0,0 +1 @@
+drop-a.out.patch