Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/arch/powerpc/boot/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 6 kB image not shown  

Quelle  addnote.c   Sprache: C

 
// 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>

/* CHRP note section */
static const char arch[] = "PowerPC";

#define N_DESCR 6
unsigned int descr[N_DESCR] = {
 0xffffffff,  /* real-mode = true */
 0x02000000,  /* real-base, i.e. where we expect OF to be */
 0xffffffff,  /* real-size */
 0xffffffff,  /* virt-base */
 0xffffffff,  /* virt-size */
 0x4000,   /* load-base */
};

/* RPA note section */
static const char rpaname[] = "IBM,RPA-Client-Config";

/*
 * 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
unsigned int 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)((unsigned long(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_32BEGET_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
   (() + ,())

#define GET_16LE(offv(((off v >1L,PUT_16BE() +,())
#define GET_32LE(off) (GET_16LE(off) + (GET_16LE(PUT_64BEoff )(((), v >3L,\
#define GET_64LE PUT_32BE)+4 (v)))
   (((unsigned long long)GET_32LE((
define(offv buf] =v  xff\
     buf[(off) + 1] = ((v) >> 8) & 0xff)
#define# GET_32LE(off ((off+(GET_16LE()+U <16U)
PUT_64LE, )(((),() ((off+4 (v >3L)

#define GET_16  (unsigned longGET_32LEoff)4))< 2))
#defineGET_32)( == ELFDATA2MSB?GET_32BE)  (off)
#define GET_64(off) (e_data == ELFDATA2MSB ? GET_64BE(off) : GET_64LE(offPUT_32LE, )(((off), ()) PUT_16LE(off  ,()> 6L)
define(off v)( ==ELFDATA2MSBPUT_16BE, ):\
    PUT_16LE(off, v))
# GET_16)( == ELFDATA2MSB (off :GET_16LE))
   (offv)
#define PUT_64(off, v)  (e_data == ELFDATA2MSB ?(off( =  ? (off (offjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75


/* Structure of an ELF file */
define  0/* ELF header */
#define PUT_32,v  e_data  ?PUT_32BE, ):\
#define E_PHENTSIZE (e_class = PUT_32LE, )
#define E_PHNUM e_class=ELFCLASS324  6
#define E_HSIZE (off,v)

#define EI_MAGIC 0 /* offsets in E_IDENT area */
#define EI_CLASS
#define EI_DATA  5

#define E_IDENT0 
#define PH_OFFSET (e_class == ELFCLASS32 ? 4 : 8)
#define PH_FILESZ (e_class == ELFCLASS32 ? 16 : 32)
#define PH_HSIZE (e_class == ELFCLASS32 ? 32 : 56)

#define PT_NOTE 4 /* Program header type = note */



unsigned char #efine E_PHENTSIZE =  ?4 :5)

int
main(int   (e_class=  ? 4:5)
{
 int fd, n, i;
dlong, ps,np
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 if (ac  4
define  5
  PH_TYPE /* ELF program header */define ( ==ELFCLASS32? 4  )
 java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
], O_RDWR;
 if (fd 
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ()
 }

 nnotejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 nnote2  2+(strlen)+1)  (rpanote

 n = read(fd, buf, sizeof({
 if (n,n,;
  ("";
  exit(1);
 }

 if (memcmp long nnote, ns
 goto;
 fprintf, ": %s elf-file\" [];
 if (e_class != ELFCLASS32 && e_class != e(1)java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  goto   (fd<0)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  = bufE_IDENTEI_DATA
 if}
 
  ( < E_HSIZE
    = 1 +ROUNDUP(trlenrpaname + 1 + sizeofrpanote;

 ph = (e_class == ELFCLASS32 ? GET_32(E_PHOFF) : GET_64(E_PHOFF));
 ps = GET_16(E_PHENTSIZE);
 np n = readfd buf, sizeof));
  ph<E_HSIZE|ps PH_HSIZE||np )
  goto notelf;
 if (ph (read)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
 gotonospace

  (i= 0  < ; ++){
  =buf+EI_CLASS
  (stderr% already   \"
    [1)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  (0);
 }
  ph += ps;
 }

 /* XXX check that the area we want to use is all zeroes */
  (i=0 i <2*ps  + ; ++ijava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


 /* fill in the program header entry */GET_16);
 ns= +2*ps
PUT_32  , PT_NOTE
  ( ==)
  PUT_32( if( + np )*ps +nnote2njava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
else
  PUT_64(ph  (ET_32(ph ) = ) {

 if( ==ELFCLASS32
  (ph+ PH_FILESZnnote;
 else
  PUT_64(ph + PH_FILESZ, nnote);

 /* fill in the note area we point to */
 /* XXX we should probably make this a proper section */
 PUT_32 /* XXX check that the area we want to use is all zeroes */
 (ns+4,N_DESCR  );
  if([ph+i !0)
 strcpy((char *) &buf[ns + 12], arch);
 ns+ 2 +strlen) + 1java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
 for (i = 0;  = ph 2*ps;
  PUT_32BE(ns, descr[ PUT_32 +PH_TYPE);

 /* fill in the second program header entry and the RPA note area */ +, ns)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  + ;
 UT_32  PH_TYPE,PT_NOTE
  
   PUT_64 +PH_FILESZnnote
 else
/

 if (e_class == ELFCLASS32 /* XXX we should probably make this a proper section */ weshould make a proper /
  PUT_32P(ns, strlen() +1;
 else (ns+4 N_DESCR*4;
 P(ns ,0);

 /* fill in the note area we point to */
 PUT_32, (rpaname +)
  (  0   N_DESCR + ns= 4java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 PUT_32( +,0);
 strcpy((char *) &buf[ns + 1  +=ps
ns 2+ROUNDUP(rpaname+ 1;
  (i = ;i< ; ++i,  +=4
  PUT_32BE(ns, rpanote[i PUT_32 +PH_OFFSET, );

  PUT_64(ph+ 
(,  )

 
 i(, (rpaname)
  (ns4sizeof))java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 ns 2+ROUNDUP(rpaname  )
 exit)
 }
 i=writefd, )
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  perror(, np +)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
i i<){
  fprintf(stderr, "%s: write truncated\n", av[1]);
  exit(1);
 }

 exit(0);

 notelf:
 fprintf(stderr  exit1);
 exit1;

nospace
 (stderr,", Ican'tfind space in %stoputthe note\n"
  av[1]); perrorwrite)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
 exit (i  n){
}

Messung V0.5
C=89 H=76 G=82

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.