Skip to contentSkip to conversation

patch for HPUX SOM on non-HPUX systems

PATCH Helge Deller 2 participants 2 messages Dec 26, 2007

lore
Share & tools
lore
#0 lore raw

I found this pretty interesting, esp. in case we want to enhance our kernel SOM support in future. Helge

--------------- Forwarded message (begin)

Subject: patch for HPUX SOM on non-HPUX systems
From: David Leonard <[email protected]>
Date: Wed, 12 Dec 2007 02:23:10 +0100
Newsgroup: gmane.comp.gnu.binutils.bugs

Here is a patch to allow hpux's som target to build on non-hpux hosts. I have been using it in a linux x86_64 environment which has a different long size and endianness. Also tested on hpux11.00.
Enjoy!

notes:
The patch applies to binutils-2.18, and is licensed under gpl v2. I was careful to make only minimal changes to som.c.
The header files were re-written by hand, mainly to use preprocessor hex constants instead of bit fields. They were cribbed from online documentation by hp, and the few missing constants were extracted from hpux header files. The bulk of the patch was generated by a perl script to perform reliable byte swapping of the structures.
This work is part of a cross compiler effort here at Quest, So, I anticipate some more stress testing soon.

Quoted 2 lines · Jeff Law

The SOM code has never been designed to be cross-compilation safe, particularly in terms of endianness and datatype size issues.

http://sources.redhat.com/ml/binutils/2002-01/msg00168.html

--------------- Forwarded message (end)

som/spacehdr.h +71 -0
Index: include/som/spacehdr.h
===================================================================
@@ -0,0 +1,71 @@
+/* Declaration of data structures for the PA-SOM object format.
+   (c) 2007, Quest Software, Inc. All rights reserved.
+   Written by David Leonard based on information published by Hewlett-Packard.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _bfd_som_spacehdr_h
+#define _bfd_som_spacehdr_h
+
+#include "aouttypes.h"
+
+struct space_dictionary_record {
+    union name_pt   name;
+    uint32_t        flags;
+#define SPA_IS_LOADABLE                 0x80000000
+#define SPA_IS_DEFINED                  0x40000000
+#define SPA_IS_PRIVATE                  0x20000000
+#define SPA_HAS_INTERMEDIATE_CODE       0x10000000
+#define SPA_IS_TSPECIFIC                0x08000000
+#define SPA_IS_IGNORE_DBG               0x04000000
+#define SPA_RESERVED_MASK               0x03ff0000
+#define SPA_RESERVED_SHIFT              16
+#define SPA_SORT_KEY_MASK               0x0000ff00
+#define SPA_SORT_KEY_SHIFT              8
+#define SPA_RESERVED2_MASK              0x000000ff
+#define SPA_RESERVED2_SHIFT             0
+    int32_t         space_number;
+    int32_t         subspace_index;
+    uint32_t        subspace_quantity;
+    int32_t         loader_fix_index;
+    uint32_t        loader_fix_quantity;
+    int32_t         init_pointer_index;
+    uint32_t        init_pointer_quantity;
+};
+
+struct internal_space_dictionary_record {
+    union internal_name_pt name;
+    bfd_boolean     is_loadable;
+    bfd_boolean     is_defined;
+    bfd_boolean     is_private;
+    bfd_boolean     has_intermediate_code;
+    bfd_boolean     is_tspecific;
+    bfd_boolean     is_ignore_dbg;
+    uint8_t         sort_key;
+    int32_t         space_number;
+    int32_t         subspace_index;
+    uint32_t        subspace_quantity;
+    int32_t         loader_fix_index;
+    uint32_t        loader_fix_quantity;
+    int32_t         init_pointer_index;
+    uint32_t        init_pointer_quantity;
+};
+
+#define SPAHDR  struct space_dictionary_record
+#define SPAHSZ  sizeof(SPAHDR)
+
+#endif /* _bfd_som_spacehdr_h */
som/somswap.h +587 -0

587 lines not on this page · raw message

som/syms.h +104 -0

104 lines not on this page · raw message

som/aouttypes.h +43 -0

43 lines not on this page · raw message

som/filehdr.h +81 -0

81 lines not on this page · raw message

som/compunit.h +54 -0

54 lines not on this page · raw message

som/scnhdr.h +91 -0

91 lines not on this page · raw message

som/lst.h +123 -0

123 lines not on this page · raw message

som/reloc.h +75 -0

75 lines not on this page · raw message

som/a.out.h +32 -0
Index: include/som/a.out.h
===================================================================
@@ -0,0 +1,32 @@
+/* Declaration of data structures for the PA-SOM object format.
+   (c) 2007, Quest Software, Inc. All rights reserved.
+   Written by David Leonard based on information published by Hewlett-Packard.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _bfd_som_a_out_h
+#define _bfd_som_a_out_h
+
+#include "filehdr.h"
+#include "aouthdr.h"
+#include "scnhdr.h"
+#include "spacehdr.h"
+#include "compunit.h"
+#include "reloc.h"
+#include "syms.h"
+
+#endif /* _bfd_som_a_out_h */
som/aouthdr.h +107 -0

107 lines not on this page · raw message

som.c +217 -236

936 lines not on this page · raw message

som.h +10 -58

100 lines not on this page · raw message

#1 lore raw
Quoted 8 lines

This work is part of a cross compiler effort here at Quest, So, I anticipate some more stress testing soon.

Quoted 2 lines · Jeff Law

The SOM code has never been designed to be cross-compilation safe, particularly in terms of endianness and datatype size issues.

http://sources.redhat.com/ml/binutils/2002-01/msg00168.html

This is a significant work. Before it can be considered for inclusion in binutils, a copyright assignment needs to be on file for the author with the FSF.

When this is done, submit the change to the binutils list. CC or ping me, and I will review the change.

As a note, binutils is now licensed under GPL version 3 or later.

Dave

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)