Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Fix a wrong flag and KNF.
details: https://anonhg.NetBSD.org/src/rev/beee02277671
branches: trunk
changeset: 819414:beee02277671
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Dec 03 09:20:55 2016 +0000
description:
Fix a wrong flag and KNF.
diffstat:
sys/lib/libsa/loadfile.h | 48 +++++++++++++++++++++---------------------
sys/lib/libsa/loadfile_elf32.c | 36 ++++++++++++++----------------
2 files changed, 41 insertions(+), 43 deletions(-)
diffs (208 lines):
diff -r ac738a790383 -r beee02277671 sys/lib/libsa/loadfile.h
--- a/sys/lib/libsa/loadfile.h Sat Dec 03 07:23:08 2016 +0000
+++ b/sys/lib/libsa/loadfile.h Sat Dec 03 09:20:55 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile.h,v 1.12 2010/08/25 16:30:01 christos Exp $ */
+/* $NetBSD: loadfile.h,v 1.13 2016/12/03 09:20:55 maxv Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -34,36 +34,36 @@
*/
#define MARK_START 0
#define MARK_ENTRY 1
-#define MARK_DATA 2
-#define MARK_NSYM 3
+#define MARK_DATA 2
+#define MARK_NSYM 3
#define MARK_SYM 4
-#define MARK_END 5
-#define MARK_MAX 6
+#define MARK_END 5
+#define MARK_MAX 6
/*
* Bit flags for sections to load
*/
-#define LOAD_TEXT 0x0001
-#define LOAD_TEXTA 0x0002
-#define LOAD_DATA 0x0004
-#define LOAD_BSS 0x0008
-#define LOAD_SYM 0x0010
-#define LOAD_HDR 0x0020
+#define LOAD_TEXT 0x0001
+#define LOAD_TEXTA 0x0002
+#define LOAD_DATA 0x0004
+#define LOAD_BSS 0x0008
+#define LOAD_SYM 0x0010
+#define LOAD_HDR 0x0020
#define LOAD_NOTE 0x0040
#define LOAD_ALL 0x007f
#define LOAD_MINIMAL 0x002f
#define LOAD_BACKWARDS 0x0050
-#define COUNT_TEXT 0x0100
-#define COUNT_TEXTA 0x0200
-#define COUNT_DATA 0x0400
-#define COUNT_BSS 0x0800
-#define COUNT_SYM 0x1000
-#define COUNT_HDR 0x2000
+#define COUNT_TEXT 0x0100
+#define COUNT_TEXTA 0x0200
+#define COUNT_DATA 0x0400
+#define COUNT_BSS 0x0800
+#define COUNT_SYM 0x1000
+#define COUNT_HDR 0x2000
#define COUNT_ALL 0x3f00
-int loadfile(const char *, u_long *, int);
-int fdloadfile(int fd, u_long *, int);
+int loadfile(const char *, u_long *, int);
+int fdloadfile(int fd, u_long *, int);
#ifndef MACHINE_LOADFILE_MACHDEP
#define MACHINE_LOADFILE_MACHDEP "machine/loadfile_machdep.h"
@@ -72,23 +72,23 @@
#ifdef BOOT_ECOFF
#include <sys/exec_ecoff.h>
-int loadfile_coff(int, struct ecoff_exechdr *, u_long *, int);
+int loadfile_coff(int, struct ecoff_exechdr *, u_long *, int);
#endif
#if defined(BOOT_ELF32) || defined(BOOT_ELF64)
#include <sys/exec_elf.h>
#ifdef BOOT_ELF32
-int loadfile_elf32(int, Elf32_Ehdr *, u_long *, int);
+int loadfile_elf32(int, Elf32_Ehdr *, u_long *, int);
#endif
#ifdef BOOT_ELF64
-int loadfile_elf64(int, Elf64_Ehdr *, u_long *, int);
+int loadfile_elf64(int, Elf64_Ehdr *, u_long *, int);
#endif
#endif /* BOOT_ELF32 || BOOT_ELF64 */
#ifdef BOOT_AOUT
#include <sys/exec_aout.h>
-int loadfile_aout(int, struct exec *, u_long *, int);
+int loadfile_aout(int, struct exec *, u_long *, int);
#endif
-extern uint32_t netbsd_version;
+extern uint32_t netbsd_version;
extern u_int netbsd_elf_class;
diff -r ac738a790383 -r beee02277671 sys/lib/libsa/loadfile_elf32.c
--- a/sys/lib/libsa/loadfile_elf32.c Sat Dec 03 07:23:08 2016 +0000
+++ b/sys/lib/libsa/loadfile_elf32.c Sat Dec 03 09:20:55 2016 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: loadfile_elf32.c,v 1.32 2016/08/31 16:22:37 martin Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.33 2016/12/03 09:20:55 maxv Exp $ */
-/*-
+/*
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -255,6 +255,10 @@
#define externalize_shdr(bo, shdr) /* nothing */
#endif /* _STANDALONE */
+#define IS_TEXT(p) (p.p_flags & PF_X)
+#define IS_DATA(p) (p.p_flags & PF_W)
+#define IS_BSS(p) (p.p_filesz < p.p_memsz)
+
int
ELFNAMEEND(loadfile)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
{
@@ -268,9 +272,9 @@
u_long offset = marks[MARK_START];
ssize_t nr;
struct __packed {
- Elf_Nhdr nh;
- uint8_t name[ELF_NOTE_NETBSD_NAMESZ + 1];
- uint8_t desc[ELF_NOTE_NETBSD_DESCSZ];
+ Elf_Nhdr nh;
+ uint8_t name[ELF_NOTE_NETBSD_NAMESZ + 1];
+ uint8_t desc[ELF_NOTE_NETBSD_DESCSZ];
} note;
char *shstr = NULL;
size_t shstrsz = 0;
@@ -315,16 +319,10 @@
(phdr[i].p_flags & (PF_W|PF_X)) == 0)
continue;
-#define IS_TEXT(p) (p.p_flags & PF_X)
-#define IS_DATA(p) (p.p_flags & PF_W)
-#define IS_BSS(p) (p.p_filesz < p.p_memsz)
- /*
- * XXX: Assume first address is lowest
- */
if ((IS_TEXT(phdr[i]) && (flags & LOAD_TEXT)) ||
(IS_DATA(phdr[i]) && (flags & LOAD_DATA))) {
-
loadseg:
+ /* XXX: Assume first address is lowest */
if (marks[MARK_DATA] == 0 && IS_DATA(phdr[i]))
marks[MARK_DATA] = LOADADDR(phdr[i].p_vaddr);
@@ -347,10 +345,9 @@
goto freephdr;
}
first = 0;
-
}
if ((IS_TEXT(phdr[i]) && (flags & (LOAD_TEXT|COUNT_TEXT))) ||
- (IS_DATA(phdr[i]) && (flags & (LOAD_DATA|COUNT_TEXT)))) {
+ (IS_DATA(phdr[i]) && (flags & (LOAD_DATA|COUNT_DATA)))) {
pos = phdr[i].p_vaddr;
if (minp > pos)
minp = pos;
@@ -410,7 +407,7 @@
/* Internalize the section headers. */
for (i = 0; i < elf->e_shnum; i++)
internalize_shdr(elf->e_ident[EI_DATA], &shp[i]);
-#endif /* ! _STANDALONE */
+#endif
/*
* First load the section names section.
@@ -469,8 +466,7 @@
if (boot_load_ctf && shstr) {
/* got a CTF section? */
if (strncmp(".SUNW_ctf",
- &shstr[shp[i].sh_name],
- 10) == 0) {
+ &shstr[shp[i].sh_name], 10) == 0) {
goto havesym;
}
}
@@ -551,7 +547,7 @@
for (i = 0; i < elf->e_shnum; i++)
externalize_shdr(elf->e_ident[EI_DATA],
&shp[i]);
-#endif /* ! _STANDALONE */
+#endif
BCOPY(shp, shpp, sz);
if (first == 0)
@@ -559,7 +555,7 @@
}
DEALLOC(shp, sz);
}
-
+
if (shstr) {
DEALLOC(shstr, shstrsz);
}
@@ -591,9 +587,11 @@
marks[MARK_SYM] = LOADADDR(elfp);
marks[MARK_END] = LOADADDR(maxp);
return 0;
+
freephdr:
DEALLOC(phdr, sz);
return 1;
+
freeshp:
DEALLOC(shp, sz);
return 1;
Home |
Main Index |
Thread Index |
Old Index