Deleted Added
full compact
main.c (316748) main.c (317623)
1/*-
2 * Copyright (c) 2007-2013 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

--- 25 unchanged lines hidden (view full) ---

34#include <libelftc.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include <unistd.h>
39
40#include "elfcopy.h"
41
1/*-
2 * Copyright (c) 2007-2013 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

--- 25 unchanged lines hidden (view full) ---

34#include <libelftc.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include <unistd.h>
39
40#include "elfcopy.h"
41
42ELFTC_VCSID("$Id: main.c 3446 2016-05-03 01:31:17Z emaste $");
42ELFTC_VCSID("$Id: main.c 3520 2017-04-17 01:47:52Z kaiwang27 $");
43
44enum options
45{
46 ECP_ADD_GNU_DEBUGLINK,
47 ECP_ADD_SECTION,
48 ECP_CHANGE_ADDR,
49 ECP_CHANGE_SEC_ADDR,
50 ECP_CHANGE_SEC_LMA,

--- 229 unchanged lines hidden (view full) ---

280create_elf(struct elfcopy *ecp)
281{
282 struct section *shtab;
283 GElf_Ehdr ieh;
284 GElf_Ehdr oeh;
285 size_t ishnum;
286
287 ecp->flags |= SYMTAB_INTACT;
43
44enum options
45{
46 ECP_ADD_GNU_DEBUGLINK,
47 ECP_ADD_SECTION,
48 ECP_CHANGE_ADDR,
49 ECP_CHANGE_SEC_ADDR,
50 ECP_CHANGE_SEC_LMA,

--- 229 unchanged lines hidden (view full) ---

280create_elf(struct elfcopy *ecp)
281{
282 struct section *shtab;
283 GElf_Ehdr ieh;
284 GElf_Ehdr oeh;
285 size_t ishnum;
286
287 ecp->flags |= SYMTAB_INTACT;
288 ecp->flags &= ~SYMTAB_EXIST;
288
289 /* Create EHDR. */
290 if (gelf_getehdr(ecp->ein, &ieh) == NULL)
291 errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
292 elf_errmsg(-1));
293 if ((ecp->iec = gelf_getclass(ecp->ein)) == ELFCLASSNONE)
294 errx(EXIT_FAILURE, "getclass() failed: %s",
295 elf_errmsg(-1));

--- 198 unchanged lines hidden (view full) ---

494 if (sec->newname != NULL)
495 free(sec->newname);
496 if (sec->pad != NULL)
497 free(sec->pad);
498 free(sec);
499 }
500 }
501
289
290 /* Create EHDR. */
291 if (gelf_getehdr(ecp->ein, &ieh) == NULL)
292 errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
293 elf_errmsg(-1));
294 if ((ecp->iec = gelf_getclass(ecp->ein)) == ELFCLASSNONE)
295 errx(EXIT_FAILURE, "getclass() failed: %s",
296 elf_errmsg(-1));

--- 198 unchanged lines hidden (view full) ---

495 if (sec->newname != NULL)
496 free(sec->newname);
497 if (sec->pad != NULL)
498 free(sec->pad);
499 free(sec);
500 }
501 }
502
503 ecp->symtab = NULL;
504 ecp->strtab = NULL;
505 ecp->shstrtab = NULL;
506
502 if (ecp->secndx != NULL) {
503 free(ecp->secndx);
504 ecp->secndx = NULL;
505 }
506}
507
508/* Create a temporary file. */
509void

--- 1070 unchanged lines hidden ---
507 if (ecp->secndx != NULL) {
508 free(ecp->secndx);
509 ecp->secndx = NULL;
510 }
511}
512
513/* Create a temporary file. */
514void

--- 1070 unchanged lines hidden ---