2023-11-23 18:03:18

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 0/5] remove the last bits of a.out support

I was working on how linux-libc-dev headers are shipped in Ubuntu and
stumbled upon seemingly unused and useless linux/a.out.h header. It
seems like it is an accidental leftover at this point.

Dimitri John Ledkov (5):
alpha: remove a.out support from tools/objstrip
alpha: stop shipping a.out.h uapi headers
m68k: stop shipping a.out.h uapi headers
x86: stop shipping a.out.h uapi headers
uapi: remove a.out.h uapi header

arch/alpha/boot/tools/objstrip.c | 52 +-----
arch/alpha/include/uapi/asm/a.out.h | 92 ----------
arch/m68k/include/uapi/asm/a.out.h | 21 ---
arch/x86/include/uapi/asm/a.out.h | 21 ---
include/uapi/Kbuild | 4 -
include/uapi/linux/a.out.h | 251 ----------------------------
6 files changed, 6 insertions(+), 435 deletions(-)
delete mode 100644 arch/alpha/include/uapi/asm/a.out.h
delete mode 100644 arch/m68k/include/uapi/asm/a.out.h
delete mode 100644 arch/x86/include/uapi/asm/a.out.h
delete mode 100644 include/uapi/linux/a.out.h

--
2.34.1


2023-11-23 18:03:36

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 1/5] alpha: remove a.out support from tools/objstrip

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.

Signed-off-by: Dimitri John Ledkov <[email protected]>
---
arch/alpha/boot/tools/objstrip.c | 52 ++++----------------------------
1 file changed, 6 insertions(+), 46 deletions(-)

diff --git a/arch/alpha/boot/tools/objstrip.c b/arch/alpha/boot/tools/objstrip.c
index 7cf92d172d..91c0ad29e1 100644
--- a/arch/alpha/boot/tools/objstrip.c
+++ b/arch/alpha/boot/tools/objstrip.c
@@ -21,17 +21,12 @@

#include <sys/fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <linux/a.out.h>
-#include <linux/coff.h>
-#include <linux/param.h>
-#ifdef __ELF__
-# include <linux/elf.h>
-# define elfhdr elf64_hdr
-# define elf_phdr elf64_phdr
-# define elf_check_arch(x) ((x)->e_machine == EM_ALPHA)
-#endif
+
+#include <linux/elf.h>
+#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_SIZE 512
@@ -55,13 +50,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];

@@ -145,7 +137,6 @@ main (int argc, char *argv[])
exit(1);
}

-#ifdef __ELF__
elf = (struct elfhdr *) buf;

if (memcmp(&elf->e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
@@ -192,37 +183,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) {
--
2.34.1

2023-11-23 18:03:41

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 3/5] m68k: stop shipping a.out.h uapi headers

Stop shipping a.out.h uapi headers, unused.

Signed-off-by: Dimitri John Ledkov <[email protected]>
---
arch/m68k/include/uapi/asm/a.out.h | 21 ---------------------
1 file changed, 21 deletions(-)
delete mode 100644 arch/m68k/include/uapi/asm/a.out.h

diff --git a/arch/m68k/include/uapi/asm/a.out.h b/arch/m68k/include/uapi/asm/a.out.h
deleted file mode 100644
index 3eb24fd8b8..0000000000
--- a/arch/m68k/include/uapi/asm/a.out.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef __M68K_A_OUT_H__
-#define __M68K_A_OUT_H__
-
-struct exec
-{
- unsigned long a_info; /* Use macros N_MAGIC, etc for access */
- unsigned a_text; /* length of text, in bytes */
- unsigned a_data; /* length of data, in bytes */
- unsigned a_bss; /* length of uninitialized data area for file, in bytes */
- unsigned a_syms; /* length of symbol table data in file, in bytes */
- unsigned a_entry; /* start address */
- unsigned a_trsize; /* length of relocation info for text, in bytes */
- unsigned a_drsize; /* length of relocation info for data, in bytes */
-};
-
-#define N_TRSIZE(a) ((a).a_trsize)
-#define N_DRSIZE(a) ((a).a_drsize)
-#define N_SYMSIZE(a) ((a).a_syms)
-
-#endif /* __M68K_A_OUT_H__ */
--
2.34.1

2023-11-23 18:03:47

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 4/5] x86: stop shipping a.out.h uapi headers

Stop shipping a.out.h uapi headers, unused.

Signed-off-by: Dimitri John Ledkov <[email protected]>
---
arch/x86/include/uapi/asm/a.out.h | 21 ---------------------
1 file changed, 21 deletions(-)
delete mode 100644 arch/x86/include/uapi/asm/a.out.h

diff --git a/arch/x86/include/uapi/asm/a.out.h b/arch/x86/include/uapi/asm/a.out.h
deleted file mode 100644
index 094c49d8ea..0000000000
--- a/arch/x86/include/uapi/asm/a.out.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ASM_X86_A_OUT_H
-#define _ASM_X86_A_OUT_H
-
-struct exec
-{
- unsigned int a_info; /* Use macros N_MAGIC, etc for access */
- unsigned a_text; /* length of text, in bytes */
- unsigned a_data; /* length of data, in bytes */
- unsigned a_bss; /* length of uninitialized data area for file, in bytes */
- unsigned a_syms; /* length of symbol table data in file, in bytes */
- unsigned a_entry; /* start address */
- unsigned a_trsize; /* length of relocation info for text, in bytes */
- unsigned a_drsize; /* length of relocation info for data, in bytes */
-};
-
-#define N_TRSIZE(a) ((a).a_trsize)
-#define N_DRSIZE(a) ((a).a_drsize)
-#define N_SYMSIZE(a) ((a).a_syms)
-
-#endif /* _ASM_X86_A_OUT_H */
--
2.34.1

2023-11-23 18:03:58

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 2/5] alpha: stop shipping a.out.h uapi headers

Stop shipping a.out.h uapi headers, unused.

Signed-off-by: Dimitri John Ledkov <[email protected]>
---
arch/alpha/include/uapi/asm/a.out.h | 92 -----------------------------
1 file changed, 92 deletions(-)
delete mode 100644 arch/alpha/include/uapi/asm/a.out.h

diff --git a/arch/alpha/include/uapi/asm/a.out.h b/arch/alpha/include/uapi/asm/a.out.h
deleted file mode 100644
index 7d692df04b..0000000000
--- a/arch/alpha/include/uapi/asm/a.out.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _UAPI__ALPHA_A_OUT_H__
-#define _UAPI__ALPHA_A_OUT_H__
-
-#include <linux/types.h>
-
-/*
- * OSF/1 ECOFF header structs. ECOFF files consist of:
- * - a file header (struct filehdr),
- * - an a.out header (struct aouthdr),
- * - one or more section headers (struct scnhdr).
- * The filhdr's "f_nscns" field contains the
- * number of section headers.
- */
-
-struct filehdr
-{
- /* OSF/1 "file" header */
- __u16 f_magic, f_nscns;
- __u32 f_timdat;
- __u64 f_symptr;
- __u32 f_nsyms;
- __u16 f_opthdr, f_flags;
-};
-
-struct aouthdr
-{
- __u64 info; /* after that it looks quite normal.. */
- __u64 tsize;
- __u64 dsize;
- __u64 bsize;
- __u64 entry;
- __u64 text_start; /* with a few additions that actually make sense */
- __u64 data_start;
- __u64 bss_start;
- __u32 gprmask, fprmask; /* bitmask of general & floating point regs used in binary */
- __u64 gpvalue;
-};
-
-struct scnhdr
-{
- char s_name[8];
- __u64 s_paddr;
- __u64 s_vaddr;
- __u64 s_size;
- __u64 s_scnptr;
- __u64 s_relptr;
- __u64 s_lnnoptr;
- __u16 s_nreloc;
- __u16 s_nlnno;
- __u32 s_flags;
-};
-
-struct exec
-{
- /* OSF/1 "file" header */
- struct filehdr fh;
- struct aouthdr ah;
-};
-
-/*
- * Define's so that the kernel exec code can access the a.out header
- * fields...
- */
-#define a_info ah.info
-#define a_text ah.tsize
-#define a_data ah.dsize
-#define a_bss ah.bsize
-#define a_entry ah.entry
-#define a_textstart ah.text_start
-#define a_datastart ah.data_start
-#define a_bssstart ah.bss_start
-#define a_gprmask ah.gprmask
-#define a_fprmask ah.fprmask
-#define a_gpvalue ah.gpvalue
-
-#define N_TXTADDR(x) ((x).a_textstart)
-#define N_DATADDR(x) ((x).a_datastart)
-#define N_BSSADDR(x) ((x).a_bssstart)
-#define N_DRSIZE(x) 0
-#define N_TRSIZE(x) 0
-#define N_SYMSIZE(x) 0
-
-#define AOUTHSZ sizeof(struct aouthdr)
-#define SCNHSZ sizeof(struct scnhdr)
-#define SCNROUND 16
-
-#define N_TXTOFF(x) \
- ((long) N_MAGIC(x) == ZMAGIC ? 0 : \
- (sizeof(struct exec) + (x).fh.f_nscns*SCNHSZ + SCNROUND - 1) & ~(SCNROUND - 1))
-
-#endif /* _UAPI__ALPHA_A_OUT_H__ */
--
2.34.1

2023-11-23 18:04:02

by Dimitri John Ledkov

[permalink] [raw]
Subject: [PATCH 5/5] uapi: remove a.out.h uapi header

Stop shipping a.out.h uapi headers, unused.

Signed-off-by: Dimitri John Ledkov <[email protected]>
---
include/uapi/Kbuild | 4 -
include/uapi/linux/a.out.h | 251 -------------------------------------
2 files changed, 255 deletions(-)
delete mode 100644 include/uapi/linux/a.out.h

diff --git a/include/uapi/Kbuild b/include/uapi/Kbuild
index 61ee6e59c9..850597437b 100644
--- a/include/uapi/Kbuild
+++ b/include/uapi/Kbuild
@@ -1,8 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
-ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/a.out.h),)
-no-export-headers += linux/a.out.h
-endif
-
ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/kvm.h),)
no-export-headers += linux/kvm.h
endif
diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
deleted file mode 100644
index 5fafde3798..0000000000
--- a/include/uapi/linux/a.out.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _UAPI__A_OUT_GNU_H__
-#define _UAPI__A_OUT_GNU_H__
-
-#define __GNU_EXEC_MACROS__
-
-#ifndef __STRUCT_EXEC_OVERRIDE__
-
-#include <asm/a.out.h>
-
-#endif /* __STRUCT_EXEC_OVERRIDE__ */
-
-#ifndef __ASSEMBLY__
-
-/* these go in the N_MACHTYPE field */
-enum machine_type {
-#if defined (M_OLDSUN2)
- M__OLDSUN2 = M_OLDSUN2,
-#else
- M_OLDSUN2 = 0,
-#endif
-#if defined (M_68010)
- M__68010 = M_68010,
-#else
- M_68010 = 1,
-#endif
-#if defined (M_68020)
- M__68020 = M_68020,
-#else
- M_68020 = 2,
-#endif
-#if defined (M_SPARC)
- M__SPARC = M_SPARC,
-#else
- M_SPARC = 3,
-#endif
- /* skip a bunch so we don't run into any of sun's numbers */
- M_386 = 100,
- M_MIPS1 = 151, /* MIPS R3000/R3000 binary */
- M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
-};
-
-#if !defined (N_MAGIC)
-#define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#endif
-#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
-#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
-#define N_SET_INFO(exec, magic, type, flags) \
- ((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0xff) << 16) \
- | (((flags) & 0xff) << 24))
-#define N_SET_MAGIC(exec, magic) \
- ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
-
-#define N_SET_MACHTYPE(exec, machtype) \
- ((exec).a_info = \
- ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
-
-#define N_SET_FLAGS(exec, flags) \
- ((exec).a_info = \
- ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
-
-/* Code indicating object file or impure executable. */
-#define OMAGIC 0407
-/* Code indicating pure executable. */
-#define NMAGIC 0410
-/* Code indicating demand-paged executable. */
-#define ZMAGIC 0413
-/* This indicates a demand-paged executable with the header in the text.
- The first page is unmapped to help trap NULL pointer references */
-#define QMAGIC 0314
-
-/* Code indicating core file. */
-#define CMAGIC 0421
-
-#if !defined (N_BADMAG)
-#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
- && N_MAGIC(x) != NMAGIC \
- && N_MAGIC(x) != ZMAGIC \
- && N_MAGIC(x) != QMAGIC)
-#endif
-
-#define _N_HDROFF(x) (1024 - sizeof (struct exec))
-
-#if !defined (N_TXTOFF)
-#define N_TXTOFF(x) \
- (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
- (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
-#endif
-
-#if !defined (N_DATOFF)
-#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
-#endif
-
-#if !defined (N_TRELOFF)
-#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
-#endif
-
-#if !defined (N_DRELOFF)
-#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
-#endif
-
-#if !defined (N_SYMOFF)
-#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
-#endif
-
-#if !defined (N_STROFF)
-#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
-#endif
-
-/* Address of text segment in memory after it is loaded. */
-#if !defined (N_TXTADDR)
-#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
-#endif
-
-/* Address of data segment in memory after it is loaded. */
-#ifndef __KERNEL__
-#include <unistd.h>
-#endif
-#if defined(__i386__) || defined(__mc68000__)
-#define SEGMENT_SIZE 1024
-#else
-#ifndef SEGMENT_SIZE
-#ifndef __KERNEL__
-#define SEGMENT_SIZE getpagesize()
-#endif
-#endif
-#endif
-
-#define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
-
-#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
-
-#ifndef N_DATADDR
-#define N_DATADDR(x) \
- (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
- : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
-#endif
-
-/* Address of bss segment in memory after it is loaded. */
-#if !defined (N_BSSADDR)
-#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
-#endif
-
-#if !defined (N_NLIST_DECLARED)
-struct nlist {
- union {
- char *n_name;
- struct nlist *n_next;
- long n_strx;
- } n_un;
- unsigned char n_type;
- char n_other;
- short n_desc;
- unsigned long n_value;
-};
-#endif /* no N_NLIST_DECLARED. */
-
-#if !defined (N_UNDF)
-#define N_UNDF 0
-#endif
-#if !defined (N_ABS)
-#define N_ABS 2
-#endif
-#if !defined (N_TEXT)
-#define N_TEXT 4
-#endif
-#if !defined (N_DATA)
-#define N_DATA 6
-#endif
-#if !defined (N_BSS)
-#define N_BSS 8
-#endif
-#if !defined (N_FN)
-#define N_FN 15
-#endif
-
-#if !defined (N_EXT)
-#define N_EXT 1
-#endif
-#if !defined (N_TYPE)
-#define N_TYPE 036
-#endif
-#if !defined (N_STAB)
-#define N_STAB 0340
-#endif
-
-/* The following type indicates the definition of a symbol as being
- an indirect reference to another symbol. The other symbol
- appears as an undefined reference, immediately following this symbol.
-
- Indirection is asymmetrical. The other symbol's value will be used
- to satisfy requests for the indirect symbol, but not vice versa.
- If the other symbol does not have a definition, libraries will
- be searched to find a definition. */
-#define N_INDR 0xa
-
-/* The following symbols refer to set elements.
- All the N_SET[ATDB] symbols with the same name form one set.
- Space is allocated for the set in the text section, and each set
- element's value is stored into one word of the space.
- The first word of the space is the length of the set (number of elements).
-
- The address of the set is made into an N_SETV symbol
- whose name is the same as the name of the set.
- This symbol acts like a N_DATA global symbol
- in that it can satisfy undefined external references. */
-
-/* These appear as input to LD, in a .o file. */
-#define N_SETA 0x14 /* Absolute set element symbol */
-#define N_SETT 0x16 /* Text set element symbol */
-#define N_SETD 0x18 /* Data set element symbol */
-#define N_SETB 0x1A /* Bss set element symbol */
-
-/* This is output from LD. */
-#define N_SETV 0x1C /* Pointer to set vector in data area. */
-
-#if !defined (N_RELOCATION_INFO_DECLARED)
-/* This structure describes a single relocation to be performed.
- The text-relocation section of the file is a vector of these structures,
- all of which apply to the text section.
- Likewise, the data-relocation section applies to the data section. */
-
-struct relocation_info
-{
- /* Address (within segment) to be relocated. */
- int r_address;
- /* The meaning of r_symbolnum depends on r_extern. */
- unsigned int r_symbolnum:24;
- /* Nonzero means value is a pc-relative offset
- and it should be relocated for changes in its own address
- as well as for changes in the symbol or section specified. */
- unsigned int r_pcrel:1;
- /* Length (as exponent of 2) of the field to be relocated.
- Thus, a value of 2 indicates 1<<2 bytes. */
- unsigned int r_length:2;
- /* 1 => relocate with value of symbol.
- r_symbolnum is the index of the symbol
- in file's the symbol table.
- 0 => relocate with the address of a segment.
- r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
- (the N_EXT bit may be set also, but signifies nothing). */
- unsigned int r_extern:1;
- /* Four bits that aren't used, but when writing an object file
- it is desirable to clear them. */
- unsigned int r_pad:4;
-};
-#endif /* no N_RELOCATION_INFO_DECLARED. */
-
-#endif /*__ASSEMBLY__ */
-#endif /* _UAPI__A_OUT_GNU_H__ */
--
2.34.1

2023-11-23 18:49:11

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 3/5] m68k: stop shipping a.out.h uapi headers

Hi Dimitri,

Thanks for your patch!

On Thu, Nov 23, 2023 at 7:03 PM Dimitri John Ledkov
<[email protected]> wrote:
> Stop shipping a.out.h uapi headers, unused.

Yep, since commit 987f20a9dcce3989 ("a.out: Remove the a.out implementation")
in v6.1.

> Signed-off-by: Dimitri John Ledkov <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-11-24 06:02:30

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH 0/5] remove the last bits of a.out support

Dimitri John Ledkov <[email protected]> writes:

> I was working on how linux-libc-dev headers are shipped in Ubuntu and
> stumbled upon seemingly unused and useless linux/a.out.h header. It
> seems like it is an accidental leftover at this point.

How do you see that they are unused?

Are they never exported to userspace?

Are there any userspace programs that care?

Performing a quick debian code search I see chromium, qt6, ruby-rogue, hurd,
bazel_bootstrap, aboot, cde.

I can imagine all kinds of reasons old code could be using headers for a
historical format. Some of them are quite legitimate, and some of them
are quite silly. If it is old code like aboot it may be that it is
difficult to test any changes. If memory serves you have to flash your
firmware to change/test aboot.

Because showing userspace does not care about the definitions in a file
is a completely different problem then showing the kernel does not care
about the definitions I left them, last time I was working in this area.
Keeping headers that will never change is not cost to the kernel so it
doesn't hurt us to be nice to historical userspace.

My quick debian code search suggests that there are pieces of userspace
that still use linux/a.out.h. Are you seeing something I am not?
Do all of those pieces of code compile just fine with a.out.h missing?

Eric


> Dimitri John Ledkov (5):
> alpha: remove a.out support from tools/objstrip
> alpha: stop shipping a.out.h uapi headers
> m68k: stop shipping a.out.h uapi headers
> x86: stop shipping a.out.h uapi headers
> uapi: remove a.out.h uapi header
>
> arch/alpha/boot/tools/objstrip.c | 52 +-----
> arch/alpha/include/uapi/asm/a.out.h | 92 ----------
> arch/m68k/include/uapi/asm/a.out.h | 21 ---
> arch/x86/include/uapi/asm/a.out.h | 21 ---
> include/uapi/Kbuild | 4 -
> include/uapi/linux/a.out.h | 251 ----------------------------
> 6 files changed, 6 insertions(+), 435 deletions(-)
> delete mode 100644 arch/alpha/include/uapi/asm/a.out.h
> delete mode 100644 arch/m68k/include/uapi/asm/a.out.h
> delete mode 100644 arch/x86/include/uapi/asm/a.out.h
> delete mode 100644 include/uapi/linux/a.out.h

2023-11-24 14:37:33

by Dimitri John Ledkov

[permalink] [raw]
Subject: Re: [PATCH 0/5] remove the last bits of a.out support

On Fri, 24 Nov 2023 at 06:01, Eric W. Biederman <[email protected]> wrote:
>
> Dimitri John Ledkov <[email protected]> writes:
>
> > I was working on how linux-libc-dev headers are shipped in Ubuntu and
> > stumbled upon seemingly unused and useless linux/a.out.h header. It
> > seems like it is an accidental leftover at this point.
>
> How do you see that they are unused?
>
> Are they never exported to userspace?
>
> Are there any userspace programs that care?
>
> Performing a quick debian code search I see chromium, qt6, ruby-rogue, hurd,
> bazel_bootstrap, aboot, cde.
>
> I can imagine all kinds of reasons old code could be using headers for a
> historical format. Some of them are quite legitimate, and some of them
> are quite silly. If it is old code like aboot it may be that it is
> difficult to test any changes. If memory serves you have to flash your
> firmware to change/test aboot.
>
> Because showing userspace does not care about the definitions in a file
> is a completely different problem then showing the kernel does not care
> about the definitions I left them, last time I was working in this area.
> Keeping headers that will never change is not cost to the kernel so it
> doesn't hurt us to be nice to historical userspace.
>
> My quick debian code search suggests that there are pieces of userspace
> that still use linux/a.out.h. Are you seeing something I am not?
> Do all of those pieces of code compile just fine with a.out.h missing?
>

I will recheck the above mentioned things again, but as far as I could
tell up to this point, is that things mostly use a.out.h provided by
glibc.

Separately, I can do this change in a test-rebuild of ubuntu archive
of all packages on amd64,. as that's the only Ubuntu arch that ships
linux/a.out.h.

As far as I can tell, the legacy userspace access to linux/a.out.h can
use glibc's a.out.h instead. But yes, it would be pain, if code
changes are required to things.

> Eric
>
>
> > Dimitri John Ledkov (5):
> > alpha: remove a.out support from tools/objstrip
> > alpha: stop shipping a.out.h uapi headers
> > m68k: stop shipping a.out.h uapi headers

I think above three patches still can be merged in m68k & alpha trees.

> > x86: stop shipping a.out.h uapi headers
> > uapi: remove a.out.h uapi header
> >

And these two need further validation now, based on Eric's input.

> > arch/alpha/boot/tools/objstrip.c | 52 +-----
> > arch/alpha/include/uapi/asm/a.out.h | 92 ----------
> > arch/m68k/include/uapi/asm/a.out.h | 21 ---
> > arch/x86/include/uapi/asm/a.out.h | 21 ---
> > include/uapi/Kbuild | 4 -
> > include/uapi/linux/a.out.h | 251 ----------------------------
> > 6 files changed, 6 insertions(+), 435 deletions(-)
> > delete mode 100644 arch/alpha/include/uapi/asm/a.out.h
> > delete mode 100644 arch/m68k/include/uapi/asm/a.out.h
> > delete mode 100644 arch/x86/include/uapi/asm/a.out.h
> > delete mode 100644 include/uapi/linux/a.out.h



--
okurrr,

Dimitri

2023-11-24 18:07:35

by Dimitri John Ledkov

[permalink] [raw]
Subject: Re: [PATCH 0/5] remove the last bits of a.out support

On Fri, 24 Nov 2023 at 14:36, Dimitri John Ledkov
<[email protected]> wrote:
>
> On Fri, 24 Nov 2023 at 06:01, Eric W. Biederman <[email protected]> wrote:
> >
> > Dimitri John Ledkov <[email protected]> writes:
> >
> > > I was working on how linux-libc-dev headers are shipped in Ubuntu and
> > > stumbled upon seemingly unused and useless linux/a.out.h header. It
> > > seems like it is an accidental leftover at this point.
> >
> > How do you see that they are unused?

When I did my code search the only and last remaining userspace code
that imports linux/a.out.h it is the objtool that is patched in these
patch series.
It is also vendored as copy in aboot tool, which has been patched in
many downstreams to use a.out.h instead of linux/a.out.h.

> >
> > Are they never exported to userspace?
> >

Yes it is exported for user-code to compile against. The question is
if any of them import it, or use it.

> > Are there any userspace programs that care?

Just the alpha objstrip tool in these series.

> >
> > Performing a quick debian code search I see chromium, qt6, ruby-rogue, hurd,
> > bazel_bootstrap, aboot, cde.
> >

chromium qt6 bazel cde - vendor a full linux source tree with
manifests, to build actual linux kernel as offered by a vendored
project or for bootstrapping toolchains. These are all unused by the
resulting userspace.

aboot - has the copy of arch/alpha/boot/tools/objstrip.c which is
patched in these series, to support booting a.out based alpha which is
gone. So self-referencing.

ruby-rogue is syntax highlight for Syzlang which is kernel syscall
fuzzing language, by definition it highlights things inside kernel,
and thus will be unused highlight code for kernel sources that dropped
a.out.h support and will do correctly syntax highlight for syszlang
source code that targets a.out.h capable kernels.

hurd - it is a pfinet server based on a vendored copy of linux source
tree, with its own copy of linux/a.out.h and its own copy of
affs_fs_i.h. It is based on the linux 2.2.12 partial tree. If they
upgrade networking code to a newer linux copy, it will be gone there
too.

> > I can imagine all kinds of reasons old code could be using headers for a
> > historical format. Some of them are quite legitimate, and some of them
> > are quite silly. If it is old code like aboot it may be that it is
> > difficult to test any changes. If memory serves you have to flash your
> > firmware to change/test aboot.
> >
> > Because showing userspace does not care about the definitions in a file
> > is a completely different problem then showing the kernel does not care
> > about the definitions I left them, last time I was working in this area.
> > Keeping headers that will never change is not cost to the kernel so it
> > doesn't hurt us to be nice to historical userspace.
> >
> > My quick debian code search suggests that there are pieces of userspace
> > that still use linux/a.out.h. Are you seeing something I am not?

Was your search
https://codesearch.debian.net/search?q=linux%2Fa.out.h&literal=1&perpkg=1
?

In which case none of them are header imports as compiled into any of
the userspace code. They are all vendored copies of linux code, either
unused or compiled as a kernel.

> > Do all of those pieces of code compile just fine with a.out.h missing?
> >

Yes, as none of them import it =) with objstrip being the last one.

>
> I will recheck the above mentioned things again, but as far as I could
> tell up to this point, is that things mostly use a.out.h provided by
> glibc.
>
> Separately, I can do this change in a test-rebuild of ubuntu archive
> of all packages on amd64,. as that's the only Ubuntu arch that ships
> linux/a.out.h.
>
> As far as I can tell, the legacy userspace access to linux/a.out.h can
> use glibc's a.out.h instead. But yes, it would be pain, if code
> changes are required to things.
>
> > Eric
> >
> >
> > > Dimitri John Ledkov (5):
> > > alpha: remove a.out support from tools/objstrip
> > > alpha: stop shipping a.out.h uapi headers
> > > m68k: stop shipping a.out.h uapi headers
>
> I think above three patches still can be merged in m68k & alpha trees.
>
> > > x86: stop shipping a.out.h uapi headers
> > > uapi: remove a.out.h uapi header
> > >
>
> And these two need further validation now, based on Eric's input.

I believe all examples Eric pointed out are false-positives of Linux
source tree itself dating back to copies of 2.1.22.
Thus this should all be merged.

>
> > > arch/alpha/boot/tools/objstrip.c | 52 +-----
> > > arch/alpha/include/uapi/asm/a.out.h | 92 ----------
> > > arch/m68k/include/uapi/asm/a.out.h | 21 ---
> > > arch/x86/include/uapi/asm/a.out.h | 21 ---
> > > include/uapi/Kbuild | 4 -
> > > include/uapi/linux/a.out.h | 251 ----------------------------
> > > 6 files changed, 6 insertions(+), 435 deletions(-)
> > > delete mode 100644 arch/alpha/include/uapi/asm/a.out.h
> > > delete mode 100644 arch/m68k/include/uapi/asm/a.out.h
> > > delete mode 100644 arch/x86/include/uapi/asm/a.out.h
> > > delete mode 100644 include/uapi/linux/a.out.h

--
okurrr,

Dimitri

2023-11-24 21:28:43

by Michael Cree

[permalink] [raw]
Subject: Re: [PATCH 0/5] remove the last bits of a.out support

On Fri, Nov 24, 2023 at 12:00:15AM -0600, Eric W. Biederman wrote:
> Dimitri John Ledkov <[email protected]> writes:
> If it is old code like aboot it may be that it is
> difficult to test any changes. If memory serves you have to flash your
> firmware to change/test aboot.

No, aboot is written to the first sectors of the boot disk. Yes, there
is a special utilty in the aboot tools to write aboot to the boot
sectors and make sure that there is no overlap with the first
partition.

Cheers
Michael.


2023-11-25 04:50:17

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH 0/5] remove the last bits of a.out support

Dimitri John Ledkov <[email protected]> writes:

> On Fri, 24 Nov 2023 at 14:36, Dimitri John Ledkov
> <[email protected]> wrote:
>>
>> On Fri, 24 Nov 2023 at 06:01, Eric W. Biederman <[email protected]> wrote:
>> >
>> > Dimitri John Ledkov <[email protected]> writes:
>> >
>> > > I was working on how linux-libc-dev headers are shipped in Ubuntu and
>> > > stumbled upon seemingly unused and useless linux/a.out.h header. It
>> > > seems like it is an accidental leftover at this point.
>> >
>> > How do you see that they are unused?
>
> When I did my code search the only and last remaining userspace code
> that imports linux/a.out.h it is the objtool that is patched in these
> patch series.
> It is also vendored as copy in aboot tool, which has been patched in
> many downstreams to use a.out.h instead of linux/a.out.h.

It sounds like you have done your homework.

Please just document (as you in your reply to me) in your cover letter
or elsewhere in the changes so that it is clear that due diligence has
been performed and userspace should not break with this change.

[snip]

> Was your search
> https://codesearch.debian.net/search?q=linux%2Fa.out.h&literal=1&perpkg=1
> ?

Pretty much. I didn't have the perpkg=1.

Debian code search is the most comprehensive code search I am aware
of so I took a quick look.

Since it appears the only users are vendored versions of linux/a.out.h
then it should be possible to make this change without breaking
userspace. If it turns that is wrong the changes can be reverted.

Eric

2023-11-30 19:26:02

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 4/5] x86: stop shipping a.out.h uapi headers


* Dimitri John Ledkov <[email protected]> wrote:

> Stop shipping a.out.h uapi headers, unused.
>
> Signed-off-by: Dimitri John Ledkov <[email protected]>
> ---
> arch/x86/include/uapi/asm/a.out.h | 21 ---------------------
> 1 file changed, 21 deletions(-)
> delete mode 100644 arch/x86/include/uapi/asm/a.out.h
>
> diff --git a/arch/x86/include/uapi/asm/a.out.h b/arch/x86/include/uapi/asm/a.out.h
> deleted file mode 100644
> index 094c49d8ea..0000000000
> --- a/arch/x86/include/uapi/asm/a.out.h
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> -#ifndef _ASM_X86_A_OUT_H
> -#define _ASM_X86_A_OUT_H
> -
> -struct exec
> -{
> - unsigned int a_info; /* Use macros N_MAGIC, etc for access */
> - unsigned a_text; /* length of text, in bytes */
> - unsigned a_data; /* length of data, in bytes */
> - unsigned a_bss; /* length of uninitialized data area for file, in bytes */
> - unsigned a_syms; /* length of symbol table data in file, in bytes */
> - unsigned a_entry; /* start address */
> - unsigned a_trsize; /* length of relocation info for text, in bytes */
> - unsigned a_drsize; /* length of relocation info for data, in bytes */
> -};
> -
> -#define N_TRSIZE(a) ((a).a_trsize)
> -#define N_DRSIZE(a) ((a).a_drsize)
> -#define N_SYMSIZE(a) ((a).a_syms)
> -
> -#endif /* _ASM_X86_A_OUT_H */

Acked-by: Ingo Molnar <[email protected]>

Thanks,

Ingo