From nobody@FreeBSD.org  Tue Feb  9 13:50:35 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6677E106568B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  9 Feb 2010 13:50:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5601D8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  9 Feb 2010 13:50:35 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o19DoZRG007387
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 9 Feb 2010 13:50:35 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o19DoZf9007386;
	Tue, 9 Feb 2010 13:50:35 GMT
	(envelope-from nobody)
Message-Id: <201002091350.o19DoZf9007386@www.freebsd.org>
Date: Tue, 9 Feb 2010 13:50:35 GMT
From: Alexander Best <alexbestms@wwu.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] extend brandelf's OS knowledge
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143699
>Category:       bin
>Synopsis:       [patch] brandelf(1): extend brandelf's OS knowledge
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 09 14:00:08 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun May 04 04:15:29 UTC 2014
>Originator:     Alexander Best
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD otaku 9.0-CURRENT FreeBSD 9.0-CURRENT #14 r203556M: Sun Feb  7 16:32:35 CET 2010     root@otaku:/usr/obj/usr/src/sys/ARUNDEL  amd64
>Description:
this patch adds extra functionality to brandelf so it's able to brand all elf types defined by POSIX.1-2008.

the patchset has been discussed in this thread:

http://lists.freebsd.org/pipermail/freebsd-hackers/2010-January/030470.html

some people liked the idea of brandelf being extended this way, while others disliked the idea due to the fact that freebsd itself isn't able to run any elf binaries apart from FreeBSD(9) Linux(3) Solaris(6) SVR4(0).

personally i didn't see the connection between brand'elfing binaries and running them. brandelf's purpose also includes simply branding binaries without running them. think of a bunch of NetBSD/OpenBSD/... files which should be backup'ed under FreeBSD, but are brandelf'ed improperly. in this case the patch would come in handy.

cheers.
alex
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: usr.bin/brandelf/brandelf.1
===================================================================
--- usr.bin/brandelf/brandelf.1	(revision 202848)
+++ usr.bin/brandelf/brandelf.1	(working copy)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 6, 1997
+.Dd January 23, 2010
 .Dt BRANDELF 1
 .Os
 .Sh NAME
@@ -62,10 +62,25 @@
 .Ar string
 ABI type.
 Currently supported ABIs are
+.Dq Li SVR4 ,
+.Dq Li HPUX ,
+.Dq Li NetBSD ,
+.Dq Li Linux ,
+.Dq Li Hurd ,
+.Dq Li 86Open ,
+.Dq Li Solaris ,
+.Dq Li AIX ,
+.Dq Li IRIX ,
 .Dq Li FreeBSD ,
-.Dq Li Linux ,
+.Dq Li TRU64 ,
+.Dq Li Modesto ,
+.Dq Li OpenBSD ,
+.Dq Li OpenVMS ,
+.Dq Li HPNSK ,
+.Dq Li AROS ,
+.Dq Li FenixOS
 and
-.Dq Li SVR4 .
+.Dq Li ARM .
 .It Ar file
 If
 .Fl t Ar string
@@ -95,7 +110,7 @@
 .Rs
 .%A The Santa Cruz Operation, Inc.
 .%T System V Application Binary Interface
-.%D April 29, 1998 (DRAFT)
+.%D October 26, 2009 (DRAFT)
 .%U http://www.sco.com/developer/devspecs/
 .Re
 .Sh HISTORY
Index: usr.bin/brandelf/brandelf.c
===================================================================
--- usr.bin/brandelf/brandelf.c	(revision 202848)
+++ usr.bin/brandelf/brandelf.c	(working copy)
@@ -49,12 +49,25 @@
 	const char *str;
 	int value;
 };
-/* XXX - any more types? */
 static struct ELFtypes elftypes[] = {
-	{ "FreeBSD",	ELFOSABI_FREEBSD },
+	{ "SVR4",	ELFOSABI_NONE },
+	{ "HPUX",	ELFOSABI_HPUX },
+	{ "NetBSD",	ELFOSABI_NETBSD },
 	{ "Linux",	ELFOSABI_LINUX },
+	{ "Hurd",	ELFOSABI_HURD },
+	{ "86Open",	ELFOSABI_86OPEN },
 	{ "Solaris",	ELFOSABI_SOLARIS },
-	{ "SVR4",	ELFOSABI_SYSV }
+	{ "AIX",	ELFOSABI_AIX },
+	{ "IRIX",	ELFOSABI_IRIX },
+	{ "FreeBSD",	ELFOSABI_FREEBSD },
+	{ "TRU64",	ELFOSABI_TRU64 },
+	{ "Modesto",	ELFOSABI_MODESTO },
+	{ "OpenBSD",	ELFOSABI_OPENBSD },
+	{ "OpenVMS",	ELFOSABI_OPENVMS },
+	{ "HPNSK",	ELFOSABI_NSK },
+	{ "AROS",	ELFOSABI_AROS },
+	{ "FenixOS",	ELFOSABI_FENIXOS },
+	{ "ARM",	ELFOSABI_ARM }
 };
 
 int
Index: sys/sys/elf_common.h
===================================================================
--- sys/sys/elf_common.h	(revision 202848)
+++ sys/sys/elf_common.h	(working copy)
@@ -113,6 +113,7 @@
 #define	ELFOSABI_OPENVMS	13	/* Open VMS */
 #define	ELFOSABI_NSK		14	/* HP Non-Stop Kernel */
 #define	ELFOSABI_AROS		15	/* Amiga Research OS */
+#define	ELFOSABI_FENIXOS	16	/* FenixOS */
 #define	ELFOSABI_ARM		97	/* ARM */
 #define	ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
 


>Release-Note:
>Audit-Trail:

From: "Pedro F. Giffuni" <giffunip@tutopia.com>
To: bug-followup@FreeBSD.org, alexbestms@wwu.de
Cc:  
Subject: Re: bin/143699: [patch] extend brandelf
Date: Tue, 9 Feb 2010 08:26:46 -0800 (PST)

 As I noted in private to Alexander, the elftoolchain
 project has a better implementation that:
 - Uses libelf
 - Takes advantage of the FreeBSD headers
 
 https://sourceforge.net/apps/trac/elftoolchain/browser/trunk/brandelf
 
 
 
       

From: Alexander Best <alexbestms@wwu.de>
To: <bug-followup@FreeBSD.org>
Cc: "Pedro F. Giffuni" <giffunip@tutopia.com>
Subject: Re: bin/143699: [patch] extend brandelf
Date: Tue, 09 Feb 2010 18:42:44 +0100 (CET)

 thanks for the reply.
 
 indeed the libelf project has a much better implementation of brandelf than
 the one in the freebsd base dir.
 
 hopefully at some point the libelf project's work will be included into the
 base dir and replace most of the gnu (or even pre-gnu) elf binaries/libraries.
 
 however until then i don't see why existing code - although inferior to the
 libelf project's code - shouldn't be enhanced here and there.
 
 also it's a lot easier to find a committer to add a few changes to an app
 which obviously won't break stuff than to find somebody to replace an existing
 binary with a whole new one.
 
 so i completely agree with you. i'm looking forward to seeing libelf's work in
 the base dir, but until then time (or better yet code) doesn't have to stand
 still. ;)
 
 cheers.
 alex

From: "Pedro F. Giffuni" <giffunip@tutopia.com>
To: Alexander Best <alexbestms@wwu.de>, bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/143699: [patch] extend brandelf
Date: Tue, 9 Feb 2010 11:05:49 -0800 (PST)

 Actually,
 
 The code is not too different. I am OK with seeing your patch go in too.
 
 
       
State-Changed-From-To: open->suspended 
State-Changed-By: arundel 
State-Changed-When: Mon Aug 9 18:08:48 UTC 2010 
State-Changed-Why:  
Brandelf along with other elf-related tools will eventually be replaced by 
importing the BSD-licensed elftoolchain project into the FreeBSD tree. 
Once the import occurs this PR should be re-evaluated. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143699 
>Unformatted:
