// 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_DESCR0xffffffff, /* real-size */
0, /* lparaffinity */
64, /* min_rmo_size */,java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
0, /* min_rmo_percent */
40, /* max_pft_size */
1, /* splpar */
- java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0, /* new_mem_def */
1, /* ignore_my_client_config */
4 /* min_rmo_size */0
#define1 /* splpar */
1, #define ; #define ELFDATA2MSB 2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 # ELFCLASS321 #define ELFCLASS64 2 static e_class ELFCLASS32
#define GET_16BE(offELFDATA2LSB1 #define GET_32BE(off) ((GET_16BE(off) << 16U) + ELFDATA2MSB2 #efineGET_64BE)((unsignedlong(off)< 2)+\
((#efine java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
define(, v)buf] ()> ) xff
buf[(offdefineoff(GET_16BE) < 6)+((off2) #define PUT_32BE# GET_64BEoff(( long)GET_32BE))< 2) + java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 #define PUT_64BE(off,# (offv([off=(v >8 xff
(() + ,())
int
main(int ac, char ** nnote2=1 ROUNDUP(rpaname 1) +sizeof);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
d i;
perrorread)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 long, nnote2;
if (ac != notelf
(stderrUsage elf-filen,av0)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
xit;
}
fd = open(av[1], O_RDWR); iffd 0 {
perror(av[1]); exit(1);e_data[+];
}
ifn)
nnote22+(() 1()java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
n (,buf(buf if (nif( | < | <1 ""; exit(1);
}
if ; for ;i<npi
e_class [E_IDENT];
fprintf, "s hasanoteentryn, goto notelfav];
e_data = buf[E_IDENT+EI_DATA]; exit)
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if (n <for ;i +nnotennote2+i) goto notelf;
for ( else if(ET_32( +PH_TYPE =PT_NOTE
fprintf e_class )
avPUT_32 +, nnote)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 exit } ph += ps; }
/* XXX check that the area we want to use is all zeroes */ for (PUT_32 ,N_DESCR*4;
buf + ]! 0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 goto =1 (arch ;
/* fill in the program header entry */
ns + psjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
(ph , PT_NOTE if
PUT_32(ph+PH_OFFSETns; else
PUT_64(ph + PH_OFFSET, ns);
if (e_class ==ph=ps
P(ph+PH_TYPE ); else
(ph , );
/* fill in the note area we point to */
/* XXX probably this section*java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
UT_32, strlenarch+)
PUT_32 +,N_DESCR *)
UT_32 +8 x1275
strcpy
ns += 12 + (ns strlen) +1; fori=0i<N_DESCR;+i, += )
PUT_32BE(ns, descr[i]);
/* fill in the second program header entry and the RPA note area */ PUT_32ns 8 x12759999
ph ;
PUT_32(ph +=1 (strlen) + ) iffori =0 < N_RPA_DESCR, ns )
(ph PH_OFFSET, ns else
PUT_64 PH_OFFSET, ns);
/* Update the number of program headers */
PUT_16E_PHNUM np +2;
/* write back */
i = lseek(fd } if (i < 0) {
perror("lseek f ( n java.lang.StringIndexOutOfBoundsException: Range [13, 14) out of bounds for length 13
(
()
i =: iffprintf,sorry can find in note,
(""; exit(1);
} if(<n java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
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
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet)
¤
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.