32c32
< __FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 190708 2009-04-05 09:27:19Z dchagin $");
---
> __FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 196512 2009-08-24 16:19:47Z bz $");
88a89,91
> static boolean_t __elfN(freebsd_trans_osrel)(const Elf_Note *note,
> int32_t *osrel);
> static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel);
119c122,123
< .flags = BN_CAN_FETCH_OSREL
---
> .flags = BN_TRANSLATE_OSREL,
> .trans_osrel = __elfN(freebsd_trans_osrel)
121a126,171
> static boolean_t
> __elfN(freebsd_trans_osrel)(const Elf_Note *note, int32_t *osrel)
> {
> uintptr_t p;
>
> p = (uintptr_t)(note + 1);
> p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
> *osrel = *(const int32_t *)(p);
>
> return (TRUE);
> }
>
> static const char GNU_ABI_VENDOR[] = "GNU";
> static int GNU_KFREEBSD_ABI_DESC = 3;
>
> Elf_Brandnote __elfN(kfreebsd_brandnote) = {
> .hdr.n_namesz = sizeof(GNU_ABI_VENDOR),
> .hdr.n_descsz = 16, /* XXX at least 16 */
> .hdr.n_type = 1,
> .vendor = GNU_ABI_VENDOR,
> .flags = BN_TRANSLATE_OSREL,
> .trans_osrel = kfreebsd_trans_osrel
> };
>
> static boolean_t
> kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel)
> {
> const Elf32_Word *desc;
> uintptr_t p;
>
> p = (uintptr_t)(note + 1);
> p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
>
> desc = (const Elf32_Word *)p;
> if (desc[0] != GNU_KFREEBSD_ABI_DESC)
> return (FALSE);
>
> /*
> * Debian GNU/kFreeBSD embed the earliest compatible kernel version
> * (__FreeBSD_version: <major><two digit minor>Rxx) in the LSB way.
> */
> *osrel = desc[1] * 100000 + desc[2] * 1000 + desc[3];
>
> return (TRUE);
> }
>
1374,1378c1424,1426
< if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
< osrel != NULL)
< *osrel = *(const int32_t *) (note_name +
< roundup2(checknote->hdr.n_namesz,
< sizeof(Elf32_Addr)));
---
> if ((checknote->flags & BN_TRANSLATE_OSREL) != 0 &&
> checknote->trans_osrel != NULL)
> return (checknote->trans_osrel(note, osrel));
< __FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 190708 2009-04-05 09:27:19Z dchagin $");
---
> __FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 196512 2009-08-24 16:19:47Z bz $");
88a89,91
> static boolean_t __elfN(freebsd_trans_osrel)(const Elf_Note *note,
> int32_t *osrel);
> static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel);
119c122,123
< .flags = BN_CAN_FETCH_OSREL
---
> .flags = BN_TRANSLATE_OSREL,
> .trans_osrel = __elfN(freebsd_trans_osrel)
121a126,171
> static boolean_t
> __elfN(freebsd_trans_osrel)(const Elf_Note *note, int32_t *osrel)
> {
> uintptr_t p;
>
> p = (uintptr_t)(note + 1);
> p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
> *osrel = *(const int32_t *)(p);
>
> return (TRUE);
> }
>
> static const char GNU_ABI_VENDOR[] = "GNU";
> static int GNU_KFREEBSD_ABI_DESC = 3;
>
> Elf_Brandnote __elfN(kfreebsd_brandnote) = {
> .hdr.n_namesz = sizeof(GNU_ABI_VENDOR),
> .hdr.n_descsz = 16, /* XXX at least 16 */
> .hdr.n_type = 1,
> .vendor = GNU_ABI_VENDOR,
> .flags = BN_TRANSLATE_OSREL,
> .trans_osrel = kfreebsd_trans_osrel
> };
>
> static boolean_t
> kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel)
> {
> const Elf32_Word *desc;
> uintptr_t p;
>
> p = (uintptr_t)(note + 1);
> p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
>
> desc = (const Elf32_Word *)p;
> if (desc[0] != GNU_KFREEBSD_ABI_DESC)
> return (FALSE);
>
> /*
> * Debian GNU/kFreeBSD embed the earliest compatible kernel version
> * (__FreeBSD_version: <major><two digit minor>Rxx) in the LSB way.
> */
> *osrel = desc[1] * 100000 + desc[2] * 1000 + desc[3];
>
> return (TRUE);
> }
>
1374,1378c1424,1426
< if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
< osrel != NULL)
< *osrel = *(const int32_t *) (note_name +
< roundup2(checknote->hdr.n_namesz,
< sizeof(Elf32_Addr)));
---
> if ((checknote->flags & BN_TRANSLATE_OSREL) != 0 &&
> checknote->trans_osrel != NULL)
> return (checknote->trans_osrel(note, osrel));