archive.c (280932) | archive.c (295577) |
---|---|
1/*- 2 * Copyright (c) 2007-2009 Kai Wang 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#ifndef LIBELF_AR 35#include <archive.h> 36#include <archive_entry.h> 37#endif /* ! LIBELF_AR */ 38 39#include "elfcopy.h" 40 | 1/*- 2 * Copyright (c) 2007-2009 Kai Wang 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#ifndef LIBELF_AR 35#include <archive.h> 36#include <archive_entry.h> 37#endif /* ! LIBELF_AR */ 38 39#include "elfcopy.h" 40 |
41ELFTC_VCSID("$Id: archive.c 3174 2015-03-27 17:13:41Z emaste $"); | 41ELFTC_VCSID("$Id: archive.c 3287 2015-12-31 16:58:48Z emaste $"); |
42 43#define _ARMAG_LEN 8 /* length of ar magic string */ 44#define _ARHDR_LEN 60 /* length of ar header */ 45#define _INIT_AS_CAP 128 /* initial archive string table size */ 46#define _INIT_SYMOFF_CAP (256*(sizeof(uint32_t))) /* initial so table size */ 47#define _INIT_SYMNAME_CAP 1024 /* initial sn table size */ 48#define _MAXNAMELEN_SVR4 15 /* max member name length in svr4 variant */ 49 --- 327 unchanged lines hidden (view full) --- 377 char *buff; 378 size_t size; 379 int r; 380 381 ecp->rela_off = 0; 382 if (lseek(ifd, 0, SEEK_SET) == -1) 383 err(EXIT_FAILURE, "lseek failed"); 384 if ((a = archive_read_new()) == NULL) | 42 43#define _ARMAG_LEN 8 /* length of ar magic string */ 44#define _ARHDR_LEN 60 /* length of ar header */ 45#define _INIT_AS_CAP 128 /* initial archive string table size */ 46#define _INIT_SYMOFF_CAP (256*(sizeof(uint32_t))) /* initial so table size */ 47#define _INIT_SYMNAME_CAP 1024 /* initial sn table size */ 48#define _MAXNAMELEN_SVR4 15 /* max member name length in svr4 variant */ 49 --- 327 unchanged lines hidden (view full) --- 377 char *buff; 378 size_t size; 379 int r; 380 381 ecp->rela_off = 0; 382 if (lseek(ifd, 0, SEEK_SET) == -1) 383 err(EXIT_FAILURE, "lseek failed"); 384 if ((a = archive_read_new()) == NULL) |
385 errx(EXIT_FAILURE, "%s", archive_error_string(a)); | 385 errx(EXIT_FAILURE, "archive_read_new failed"); |
386 archive_read_support_format_ar(a); 387 AC(archive_read_open_fd(a, ifd, 10240)); 388 for(;;) { 389 r = archive_read_next_header(a, &entry); 390 if (r == ARCHIVE_FATAL) 391 errx(EXIT_FAILURE, "%s", archive_error_string(a)); 392 if (r == ARCHIVE_EOF) 393 break; --- 44 unchanged lines hidden (view full) --- 438ac_write_objs(struct elfcopy *ecp, int ofd) 439{ 440 struct archive *a; 441 struct archive_entry *entry; 442 struct ar_obj *obj; 443 int nr; 444 445 if ((a = archive_write_new()) == NULL) | 386 archive_read_support_format_ar(a); 387 AC(archive_read_open_fd(a, ifd, 10240)); 388 for(;;) { 389 r = archive_read_next_header(a, &entry); 390 if (r == ARCHIVE_FATAL) 391 errx(EXIT_FAILURE, "%s", archive_error_string(a)); 392 if (r == ARCHIVE_EOF) 393 break; --- 44 unchanged lines hidden (view full) --- 438ac_write_objs(struct elfcopy *ecp, int ofd) 439{ 440 struct archive *a; 441 struct archive_entry *entry; 442 struct ar_obj *obj; 443 int nr; 444 445 if ((a = archive_write_new()) == NULL) |
446 errx(EXIT_FAILURE, "%s", archive_error_string(a)); | 446 errx(EXIT_FAILURE, "archive_write_new failed"); |
447 archive_write_set_format_ar_svr4(a); 448 AC(archive_write_open_fd(a, ofd)); 449 450 /* Write the archive symbol table, even if it's empty. */ 451 entry = archive_entry_new(); 452 archive_entry_copy_pathname(entry, "/"); 453 archive_entry_set_mtime(entry, time(NULL), 0); 454 archive_entry_set_size(entry, (ecp->s_cnt + 1) * sizeof(uint32_t) + --- 69 unchanged lines hidden --- | 447 archive_write_set_format_ar_svr4(a); 448 AC(archive_write_open_fd(a, ofd)); 449 450 /* Write the archive symbol table, even if it's empty. */ 451 entry = archive_entry_new(); 452 archive_entry_copy_pathname(entry, "/"); 453 archive_entry_set_mtime(entry, time(NULL), 0); 454 archive_entry_set_size(entry, (ecp->s_cnt + 1) * sizeof(uint32_t) + --- 69 unchanged lines hidden --- |