Deleted Added
full compact
symbols.c (295577) symbols.c (300311)
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

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

29#include <err.h>
30#include <fnmatch.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include "elfcopy.h"
36
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

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

29#include <err.h>
30#include <fnmatch.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include "elfcopy.h"
36
37ELFTC_VCSID("$Id: symbols.c 3376 2016-01-26 18:41:39Z emaste $");
37ELFTC_VCSID("$Id: symbols.c 3446 2016-05-03 01:31:17Z emaste $");
38
39/* Backwards compatibility for systems with older ELF definitions. */
40#ifndef STB_GNU_UNIQUE
41#define STB_GNU_UNIQUE 10
42#endif
43
44
45/* Symbol table buffer structure. */

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

163static int
164is_needed_symbol(struct elfcopy *ecp, int i, GElf_Sym *s)
165{
166
167 /* If symbol involves relocation, it is needed. */
168 if (BIT_ISSET(ecp->v_rel, i))
169 return (1);
170
38
39/* Backwards compatibility for systems with older ELF definitions. */
40#ifndef STB_GNU_UNIQUE
41#define STB_GNU_UNIQUE 10
42#endif
43
44
45/* Symbol table buffer structure. */

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

163static int
164is_needed_symbol(struct elfcopy *ecp, int i, GElf_Sym *s)
165{
166
167 /* If symbol involves relocation, it is needed. */
168 if (BIT_ISSET(ecp->v_rel, i))
169 return (1);
170
171 /* Symbols refered by COMDAT sections are needed. */
171 /* Symbols referred by COMDAT sections are needed. */
172 if (BIT_ISSET(ecp->v_grp, i))
173 return (1);
174
175 /*
176 * For relocatable files (.o files), global and weak symbols
177 * are needed.
178 */
179 if (ecp->flags & RELOCATABLE) {

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

253
254 if (ecp->strip == STRIP_DEBUG && is_debug_symbol(s->st_info))
255 return (1);
256
257 return (0);
258}
259
260/*
172 if (BIT_ISSET(ecp->v_grp, i))
173 return (1);
174
175 /*
176 * For relocatable files (.o files), global and weak symbols
177 * are needed.
178 */
179 if (ecp->flags & RELOCATABLE) {

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

253
254 if (ecp->strip == STRIP_DEBUG && is_debug_symbol(s->st_info))
255 return (1);
256
257 return (0);
258}
259
260/*
261 * Mark symbols refered by relocation entries.
261 * Mark symbols referred by relocation entries.
262 */
263static void
264mark_reloc_symbols(struct elfcopy *ecp, size_t sc)
265{
266 const char *name;
267 Elf_Data *d;
268 Elf_Scn *s;
269 GElf_Rel r;

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

1160{
1161 struct symop *s, *ret;
1162 const char *pattern;
1163
1164 STAILQ_FOREACH(s, &ecp->v_symop, symop_list) {
1165 if ((s->op & op) == 0)
1166 continue;
1167 if (name == NULL || !strcmp(name, s->name))
262 */
263static void
264mark_reloc_symbols(struct elfcopy *ecp, size_t sc)
265{
266 const char *name;
267 Elf_Data *d;
268 Elf_Scn *s;
269 GElf_Rel r;

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

1160{
1161 struct symop *s, *ret;
1162 const char *pattern;
1163
1164 STAILQ_FOREACH(s, &ecp->v_symop, symop_list) {
1165 if ((s->op & op) == 0)
1166 continue;
1167 if (name == NULL || !strcmp(name, s->name))
1168 return (s);
1168 return (s);
1169 if ((ecp->flags & WILDCARD) == 0)
1170 continue;
1171
1172 /* Handle wildcards. */
1173 pattern = s->name;
1174 if (pattern[0] == '!') {
1175 /* Negative match. */
1176 pattern++;

--- 35 unchanged lines hidden ---
1169 if ((ecp->flags & WILDCARD) == 0)
1170 continue;
1171
1172 /* Handle wildcards. */
1173 pattern = s->name;
1174 if (pattern[0] == '!') {
1175 /* Negative match. */
1176 pattern++;

--- 35 unchanged lines hidden ---