Bug 196038

Summary: elftoolchain strip(1) -N strips everything from .o file
Product: Base System Reporter: Ed Maste <emaste>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 195561    

Description Ed Maste freebsd_committer freebsd_triage 2014-12-16 21:32:14 UTC
Binutils "strip -N <symbol> foo.o" strips only <symbol> from the output. Elftoolchain strip strips everything.

% cat foo.c
int
add1(int a)
{
        return a + 1;
}

int
add2(int a)
{
        return a + 2;
}

% cc -g -o foo.o -c foo.c

% strip -N add1 -o foo.bu.o foo.o
% file foo.bu.o
foo.bu.o: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), not stripped
% nm foo.bu.o                  
0000000000000020 T add2

% elftcstrip -N add1 -o foo.elftc.o foo.o
% file foo.elftc.o                                                        
foo.bu.o: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), stripped
% nm foo.elftc.o
nm: foo.elftc.o: no symbols
Comment 1 Ed Maste freebsd_committer freebsd_triage 2014-12-16 22:49:17 UTC
https://reviews.freebsd.org/D1327
Comment 2 commit-hook freebsd_committer freebsd_triage 2014-12-17 14:46:53 UTC
A commit references this bug:

Author: emaste
Date: Wed Dec 17 14:46:22 UTC 2014
New revision: 275862
URL: https://svnweb.freebsd.org/changeset/base/275862

Log:
  Do not strip all when stripping an explicit symbol

  When requested to strip specific symbols (-N flag) the default should be
  to strip nothing (other than the requested symbols). This is consistent
  with binutils strip(1).

  PR:		196038
  Reviewed by:	imp
  Sponsored by:	The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D1327

Changes:
  head/contrib/elftoolchain/elfcopy/main.c