Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
On recent current new sections has been added to elf notes, make sure to really take the NT_VERSION section
Baptiste Daroussin committed 14 years ago
commit cd26e0057f820a68da8aa7bd4a301260d94b0a5f
parent 65c6411
2 files changed +13 -5
modified libpkg/pkg_elf.c
@@ -273,9 +273,9 @@ pkg_get_myarch(char *dest, size_t sz)
	Elf_Note note;
	Elf_Scn *scn = NULL;
	int fd;
-
	char *src;
+
	char *src = NULL;
	char *osname;
-
	uint32_t version;
+
	uint32_t version = 0;
	int ret = EPKG_OK;
	int i;
	const char *abi;
@@ -321,10 +321,15 @@ pkg_get_myarch(char *dest, size_t sz)

	data = elf_getdata(scn, NULL);
	src = data->d_buf;
-
	memcpy(&note, src, sizeof(Elf_Note));
-
	src += sizeof(Elf_Note);
+
	while (1) {
+
		memcpy(&note, src, sizeof(Elf_Note));
+
		src += sizeof(Elf_Note);
+
		if (note.n_type == NT_VERSION)
+
			break;
+
		src += note.n_namesz + note.n_descsz;
+
	}
	osname = src;
-
	src += roundup2(note.n_namesz, 4);
+
	src += note.n_namesz;
	if (elfhdr.e_ident[EI_DATA] == ELFDATA2MSB)
		version = be32dec(src);
	else
modified libpkg/private/elf_tables.h
@@ -69,4 +69,7 @@ struct _elf_corres os_corres[] = {
#define EF_ARM_SOFT_FLOAT	0x200
#define EF_ARM_VFP_FLOAT	0x400

+
#define NT_VERSION	1
+
#define NT_ARCH	2
+

#endif /* ELF_TABLES_H_ */