// SPDX-License-Identifier: GPL-2.0-or-later /* * Program to hack in a PT_NOTE program header entry in an ELF file. * This is needed for OF on RS/6000s to load an image correctly. * Note that OF needs a program header entry for the note, not an * ELF section. * * Copyright 2000 Paul Mackerras. * * Adapted for 64 bit little endian images by Andrew Tauferner. * * Usage: addnote zImage
*/ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h>
/* * Note: setting ignore_my_client_config *should* mean that OF ignores * all the other fields, but there is a firmware bug which means that * it looks at the splpar field at least. So these values need to be * reasonable.
*/ #define N_RPA_DESCR 8 unsignedint rpanote[N_RPA_DESCR] = {
0, /* lparaffinity */
64, /* min_rmo_size */
0, /* min_rmo_percent */
40, /* max_pft_size */
1, /* splpar */
-1, /* min_load */
0, /* new_mem_def */
1, /* ignore_my_client_config */
};
/* fill in the note area we point to */ /* XXX we should probably make this a proper section */
PUT_32(ns, strlen(arch) + 1);
PUT_32(ns + 4, N_DESCR * 4);
PUT_32(ns + 8, 0x1275);
strcpy((char *) &buf[ns + 12], arch);
ns += 12 + strlen(arch) + 1; for (i = 0; i < N_DESCR; ++i, ns += 4)
PUT_32BE(ns, descr[i]);
/* fill in the second program header entry and the RPA note area */
ph += ps;
PUT_32(ph + PH_TYPE, PT_NOTE); if (e_class == ELFCLASS32)
PUT_32(ph + PH_OFFSET, ns); else
PUT_64(ph + PH_OFFSET, ns);
/* fill in the note area we point to */
PUT_32(ns, strlen(rpaname) + 1);
PUT_32(ns + 4, sizeof(rpanote));
PUT_32(ns + 8, 0x12759999);
strcpy((char *) &buf[ns + 12], rpaname);
ns += 12 + ROUNDUP(strlen(rpaname) + 1); for (i = 0; i < N_RPA_DESCR; ++i, ns += 4)
PUT_32BE(ns, rpanote[i]);
/* Update the number of program headers */
PUT_16(E_PHNUM, np + 2);
/* write back */
i = lseek(fd, (long) 0, SEEK_SET); if (i < 0) {
perror("lseek"); exit(1);
}
i = write(fd, buf, n); if (i < 0) {
perror("write"); exit(1);
} if (i < n) {
fprintf(stderr, "%s: write truncated\n", av[1]); exit(1);
}
exit(0);
notelf:
fprintf(stderr, "%s does not appear to be an ELF file\n", av[1]); exit(1);
nospace:
fprintf(stderr, "sorry, I can't find space in %s to put the note\n",
av[1]); exit(1);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.