comparison src/unexaix.c @ 294:4b85ae5eabfb r21-0b45

Import from CVS: tag r21-0b45
author cvs
date Mon, 13 Aug 2007 10:38:01 +0200
parents 57709be46d1b
children 70ad99077275
comparison
equal deleted inserted replaced
293:403535bfea94 294:4b85ae5eabfb
152 uintptr_t bss_start, 152 uintptr_t bss_start,
153 uintptr_t entry_address) 153 uintptr_t entry_address)
154 { 154 {
155 int new = -1, a_out = -1; 155 int new = -1, a_out = -1;
156 156
157 if (a_name && (a_out = open (a_name, 0)) < 0) 157 if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
158 { 158 {
159 PERROR (a_name); 159 PERROR (a_name);
160 } 160 }
161 if ((new = creat (new_name, 0666)) < 0) 161 if ((new = creat (new_name, 0666)) < 0)
162 { 162 {
324 324
325 /* fix scnptr's */ 325 /* fix scnptr's */
326 { 326 {
327 ulong ptr = section[0].s_scnptr; 327 ulong ptr = section[0].s_scnptr;
328 328
329 bias = -1;
329 for (scns = 0; scns < f_hdr.f_nscns; scns++) 330 for (scns = 0; scns < f_hdr.f_nscns; scns++)
330 { 331 {
331 struct scnhdr *s = &section[scns]; 332 struct scnhdr *s = &section[scns];
332 333
333 if (s->s_flags & STYP_PAD) /* .pad sections omitted in AIX 4.1 */ 334 if (s->s_flags & STYP_PAD) /* .pad sections omitted in AIX 4.1 */
342 if (s->s_size == 512) 343 if (s->s_size == 512)
343 s->s_size = 0; 344 s->s_size = 0;
344 } 345 }
345 s->s_scnptr = ptr; 346 s->s_scnptr = ptr;
346 } 347 }
347 else 348 else if (s->s_flags & STYP_DATA)
349 s->s_scnptr = ptr;
350 else if (!(s->s_flags & (STYP_TEXT | STYP_BSS)))
348 { 351 {
352 if (bias == -1) /* if first section after bss */
349 bias = ptr - s->s_scnptr; 353 bias = ptr - s->s_scnptr;
350 s->s_scnptr = ptr; 354
355 s->s_scnptr += bias;
356 ptr = s->s_scnptr;
351 } 357 }
352 358
353 ptr = ptr + s->s_size; 359 ptr = ptr + s->s_size;
354 } 360 }
355 } 361 }
356 362
357 /* fix other pointers */ 363 /* fix other pointers */
533 union auxent auxentry; 539 union auxent auxentry;
534 540
535 if (!lnnoptr || !f_hdr.f_symptr) 541 if (!lnnoptr || !f_hdr.f_symptr)
536 return 0; 542 return 0;
537 543
538 if ((new = open (new_name, 2)) < 0) 544 if ((new = open (new_name, O_RDWR)) < 0)
539 { 545 {
540 PERROR (new_name); 546 PERROR (new_name);
541 return -1; 547 return -1;
542 } 548 }
543 549
550 symentry.n_value += bias; 556 symentry.n_value += bias;
551 lseek (new, -SYMESZ, SEEK_CUR); 557 lseek (new, -SYMESZ, SEEK_CUR);
552 write (new, &symentry, SYMESZ); 558 write (new, &symentry, SYMESZ);
553 } 559 }
554 560
555 for (naux = symentry.n_numaux; naux-- != 0; ) 561 for (naux = symentry.n_numaux; naux != 0; --naux)
556 { 562 {
557 read (new, &auxentry, AUXESZ); 563 read (new, &auxentry, AUXESZ);
558 nsyms++; 564 nsyms++;
559 if (naux != 0 /* skip csect auxentry (last entry) */ 565 if (naux != 0 /* skip csect auxentry (last entry) */
560 && (symentry.n_sclass == C_EXT || symentry.n_sclass == C_HIDEXT)) 566 && (symentry.n_sclass == C_EXT || symentry.n_sclass == C_HIDEXT))