Fix KBI breakage by r190520 which affects older linux.ko binaries:

1) Move the new field (brand_note) to the end of the Brandinfo structure.
2) Add a new flag BI_BRAND_NOTE that indicates that the brand_note pointer
   is valid.
3) Use the brand_note field if the flag BI_BRAND_NOTE is set and as old
   modules won't have the flag set, so the new field brand_note would be
   ignored.

Suggested by:	jhb
Reviewed by:	jhb
Approved by:	kib (mentor)
MFC after:	6 days
This commit is contained in:
Dmitry Chagin 2009-04-05 09:27:19 +00:00
parent d0c7c27238
commit cd899aad76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190708
13 changed files with 24 additions and 23 deletions

View File

@ -85,7 +85,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@ -101,7 +101,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -1072,7 +1072,7 @@ static Elf32_Brandinfo linux_brand = {
.sysvec = &elf_linux_sysvec,
.interp_newpath = NULL,
.brand_note = &linux32_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
static Elf32_Brandinfo linux_glibc2brand = {
@ -1084,7 +1084,7 @@ static Elf32_Brandinfo linux_glibc2brand = {
.sysvec = &elf_linux_sysvec,
.interp_newpath = NULL,
.brand_note = &linux32_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
Elf32_Brandinfo *linux_brandlist[] = {

View File

@ -85,7 +85,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@ -101,7 +101,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -149,7 +149,7 @@ static Elf32_Brandinfo ia32_brand_info = {
.sysvec = &ia32_freebsd_sysvec,
.interp_newpath = "/libexec/ld-elf32.so.1",
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_ANY,
@ -165,7 +165,7 @@ static Elf32_Brandinfo ia32_brand_oinfo = {
.sysvec = &ia32_freebsd_sysvec,
.interp_newpath = "/libexec/ld-elf32.so.1",
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -85,7 +85,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@ -101,7 +101,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -1038,7 +1038,7 @@ static Elf32_Brandinfo linux_brand = {
.sysvec = &elf_linux_sysvec,
.interp_newpath = NULL,
.brand_note = &linux_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
static Elf32_Brandinfo linux_glibc2brand = {
@ -1050,7 +1050,7 @@ static Elf32_Brandinfo linux_glibc2brand = {
.sysvec = &elf_linux_sysvec,
.interp_newpath = NULL,
.brand_note = &linux_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
Elf32_Brandinfo *linux_brandlist[] = {

View File

@ -93,7 +93,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info);
@ -107,7 +107,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_oinfo);

View File

@ -189,7 +189,7 @@ __elfN(get_brandinfo)(struct image_params *imgp, const char *interp,
for (i = 0; i < MAX_BRANDS; i++) {
bi = elf_brand_list[i];
if (bi != NULL && hdr->e_machine == bi->machine &&
bi->brand_note != NULL) {
(bi->flags & BI_BRAND_NOTE) != 0) {
ret = __elfN(check_note)(imgp, bi->brand_note, osrel);
if (ret)
return (bi);

View File

@ -89,7 +89,7 @@ static Elf64_Brandinfo freebsd_brand_gnutools_info64 = {
.sysvec = &elf64_freebsd_sysvec,
.interp_path = "/libexec/ld-elf.so.1",
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(gnu_mips_elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@ -105,7 +105,7 @@ static Elf64_Brandinfo freebsd_brand_info64 = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = 0
.flags = BI_BRAND_NOTE
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -87,7 +87,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = 0
.flags = BI_BRAND_NOTE
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -88,7 +88,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@ -104,7 +104,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf32_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -100,7 +100,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@ -116,7 +116,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
.sysvec = &elf64_freebsd_sysvec,
.interp_newpath = NULL,
.brand_note = &elf64_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,

View File

@ -69,9 +69,10 @@ typedef struct {
const char *interp_path;
struct sysentvec *sysvec;
const char *interp_newpath;
Elf_Brandnote *brand_note;
int flags;
Elf_Brandnote *brand_note;
#define BI_CAN_EXEC_DYN 0x0001
#define BI_BRAND_NOTE 0x0002
} __ElfN(Brandinfo);
__ElfType(Auxargs);