23 static const char readstrm[] = {
"Error reading %s from input stream" };
24 static const char seek[] = {
"Set file position to %d failed" };
25 static const char isiz[] = {
"Bad image packet size %d" };
26 static const char err_checksum[] = {
"Checksum failed on %s" };
28 static const char err_reloc[] = {
"dload_get_section unable to read"
29 "sections containing relocation entries"
32 #if BITS_PER_AU > BITS_PER_BYTE
33 static const char err_alloc[] = {
"Syms->dload_allocate( %d ) failed" };
34 static const char stbl[] = {
"Bad string table offset " FMT_UI32 };
41 #if BITS_PER_AU > BITS_PER_BYTE
60 if (soffset >= dlthis->
dfile_hdr.df_scn_name_size) {
88 static void expand_sec_names(
struct dload_state *dlthis)
96 xstrings = (
char *)dlthis->
mysym->dload_allocate(dlthis->
mysym, xsize);
97 if (xstrings ==
NULL) {
101 dlthis->xstrings = xstrings;
104 for (sec = 0; sec < dlthis->
dfile_hdr.df_no_scns; sec++) {
106 next = unpack_sec_name(dlthis, *(
u32 *) &shp->
name,
curr);
145 #if BITS_PER_AU <= BITS_PER_BYTE
150 if (!module || !syms) {
166 dp = (
unsigned *)dlthis;
167 for (sz =
sizeof(
struct dload_state) /
sizeof(unsigned);
171 dlthis->
strm = module;
172 dlthis->
mysym = syms;
182 sizeof(struct doff_verify_rec_t) +
183 BYTE_TO_HOST(DOFF_ALIGN(dlthis->dfile_hdr.df_strtab_size));
185 if (dlthis->strm->set_file_posn(dlthis->strm, sec_start) != 0) {
190 if (!dlthis->dload_errcount)
193 if (dlthis->dload_errcount) {
198 #if BITS_PER_AU > BITS_PER_BYTE
202 expand_sec_names(dlthis);
206 for (sec = 0; sec < dlthis->dfile_hdr.
df_no_scns; sec++) {
209 shp->
name = dlthis->str_head + *(
u32 *) &shp->
name;
243 for (sec = 0; sec < dlthis->
dfile_hdr.df_no_scns; sec++) {
254 #define IPH_SIZE (sizeof(struct image_packet_t) - sizeof(u32))
294 if (dlthis->
strm->set_file_posn(dlthis->
strm, pos) != 0) {
300 while ((nip -= 1) >= 0) {
302 if (dlthis->
strm->read_buffer(dlthis->
strm, &ipacket,
319 if (dlthis->
strm->read_buffer
320 (dlthis->
strm, dest, ipsize) != ipsize) {
325 #if !defined(_BIG_ENDIAN) || (TARGET_AU_BITS > 16)
331 if (dlthis->
dfile_hdr.df_byte_reshuffle !=
336 dfile_hdr.df_byte_reshuffle));
338 #if TARGET_AU_BITS > 8
339 checks = dload_reverse_checksum16(dest, ipsize);
341 checks = dload_reverse_checksum(dest, ipsize);
392 dlthis->
mysym->dload_deallocate(dlthis->
mysym,
396 dlthis->
mysym->dload_deallocate(dlthis->
mysym,
399 #if BITS_PER_AU > BITS_PER_BYTE
400 if (dlthis->xstrings)
401 dlthis->
mysym->dload_deallocate(dlthis->
mysym,
406 dlthis->
mysym->dload_deallocate(dlthis->
mysym, dlthis);