guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-749-g3c08b6c


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-749-g3c08b6c
Date: Mon, 17 Feb 2014 08:38:49 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=3c08b6c1b2a8c51c3ea281c047fbbdae95bc5494

The branch, master has been updated
       via  3c08b6c1b2a8c51c3ea281c047fbbdae95bc5494 (commit)
       via  c90c81898ef41283481374e88bccd0b4e1ca9f2e (commit)
      from  a104380d5395017ce1896e79610496d056d5c985 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3c08b6c1b2a8c51c3ea281c047fbbdae95bc5494
Author: Andy Wingo <address@hidden>
Date:   Sun Feb 16 15:58:44 2014 +0100

    Add elf-symbol-value-offset, for properly relocating symtab entries
    
    * module/system/vm/elf.scm (elf-symbol-value-offset): New export.

commit c90c81898ef41283481374e88bccd0b4e1ca9f2e
Author: Andy Wingo <address@hidden>
Date:   Sun Feb 16 12:18:44 2014 +0100

    ELF linker can produce objects with native ABI
    
    * module/system/vm/elf.scm: Define more ABI types and ELF object types.
      Export the ABI, object type, and machine type values.
    
    * module/system/vm/linker.scm (<linker-reloc>, process-reloc): Allow
      rel32/1 relocs.
      (add-elf-objects, allocate-elf, link-elf): Allow the user to set an
      ABI, type, and machine-type.

-----------------------------------------------------------------------

Summary of changes:
 module/system/vm/elf.scm    |   37 +++++++++++++++++++++++++++++++++++--
 module/system/vm/linker.scm |   29 ++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/module/system/vm/elf.scm b/module/system/vm/elf.scm
index ec89d4f..b618761 100644
--- a/module/system/vm/elf.scm
+++ b/module/system/vm/elf.scm
@@ -47,6 +47,16 @@
             elf-entry elf-phoff elf-shoff elf-flags elf-ehsize
             elf-phentsize elf-phnum elf-shentsize elf-shnum elf-shstrndx
 
+            ELFOSABI_NONE ELFOSABI_HPUX ELFOSABI_NETBSD ELFOSABI_GNU
+            ELFOSABI_SOLARIS ELFOSABI_AIX ELFOSABI_IRIX ELFOSABI_FREEBSD
+            ELFOSABI_TRU64 ELFOSABI_MODESTO ELFOSABI_OPENBSD
+            ELFOSABI_ARM_AEABI ELFOSABI_ARM ELFOSABI_STANDALONE
+
+            ET_NONE ET_REL ET_EXEC ET_DYN ET_CORE
+
+            EM_NONE EM_SPARC EM_386 EM_MIPS EM_PPC EM_PPC64 EM_ARM EM_SH
+            EM_SPARCV9 EM_IA_64 EM_X86_64
+
             elf-header-len elf-header-shoff-offset
             write-elf-header
 
@@ -83,7 +93,7 @@
             elf-symbol-info elf-symbol-other elf-symbol-shndx
             elf-symbol-binding elf-symbol-type elf-symbol-visibility
 
-            elf-symbol-len write-elf-symbol
+            elf-symbol-len elf-symbol-value-offset write-elf-symbol
 
             SHN_UNDEF
 
@@ -169,9 +179,26 @@
 
 (define EV_CURRENT      1)              ; Current version
 
+(define ELFOSABI_NONE          0)      ; UNIX System V ABI */
+(define ELFOSABI_HPUX          1)      ; HP-UX
+(define ELFOSABI_NETBSD                2)      ; NetBSD.
+(define ELFOSABI_GNU           3)      ; Object uses GNU ELF extensions.
+(define ELFOSABI_SOLARIS       6)      ; Sun Solaris.
+(define ELFOSABI_AIX           7)      ; IBM AIX.
+(define ELFOSABI_IRIX          8)      ; SGI Irix.
+(define ELFOSABI_FREEBSD       9)      ; FreeBSD.
+(define ELFOSABI_TRU64         10)     ; Compaq TRU64 UNIX.
+(define ELFOSABI_MODESTO       11)     ; Novell Modesto.
+(define ELFOSABI_OPENBSD       12)     ; OpenBSD.
+(define ELFOSABI_ARM_AEABI     64)     ; ARM EABI
+(define ELFOSABI_ARM           97)     ; ARM
 (define ELFOSABI_STANDALONE     255)    ; Standalone (embedded) application
 
-(define ET_DYN          3)              ; Shared object file
+(define ET_NONE                0)              ; No file type
+(define ET_REL         1)              ; Relocatable file
+(define ET_EXEC                2)              ; Executable file
+(define ET_DYN         3)              ; Shared object file
+(define ET_CORE                4)              ; Core file
 
 ;;
 ;; Machine types
@@ -849,6 +876,12 @@
     ((8) 24)
     (else (error "bad word size" word-size))))
 
+(define (elf-symbol-value-offset word-size)
+  (case word-size
+    ((4) 4)
+    ((8) 8)
+    (else (error "bad word size" word-size))))
+
 (define (parse-elf32-symbol bv offset stroff byte-order)
   (if (<= (+ offset 16) (bytevector-length bv))
       (make-elf-symbol (let ((name (bytevector-u32-ref bv offset byte-order)))
diff --git a/module/system/vm/linker.scm b/module/system/vm/linker.scm
index 5449e86..9987a6c 100644
--- a/module/system/vm/linker.scm
+++ b/module/system/vm/linker.scm
@@ -1,6 +1,6 @@
 ;;; Guile ELF linker
 
-;; Copyright (C)  2011, 2012, 2013 Free Software Foundation, Inc.
+;; Copyright (C)  2011, 2012, 2013, 2014 Free Software Foundation, Inc.
 
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -108,13 +108,13 @@
 ;; to the address.
 ;;
 ;; Two types.  Abs32/1 and Abs64/1 are absolute offsets in bytes.
-;; Rel32/4 is a relative signed offset in 32-bit units.  Either can have
-;; an arbitrary addend as well.
+;; Rel32/1 and Rel32/1 are relative signed offsets, in 8-bit or 32-bit
+;; units, respectively.  Either can have an arbitrary addend as well.
 ;;
 (define-record-type <linker-reloc>
   (make-linker-reloc type loc addend symbol)
   linker-reloc?
-  (type linker-reloc-type) ;; rel32/4, abs32/1, abs64/1
+  (type linker-reloc-type) ;; rel32/1, rel32/4, abs32/1, abs64/1
   (loc linker-reloc-loc)
   (addend linker-reloc-addend)
   (symbol linker-reloc-symbol))
@@ -402,6 +402,11 @@ symbol, as present in @var{symtab}."
             (bytevector-s32-set! bv offset
                                  (+ (/ diff 4) (linker-reloc-addend reloc))
                                  endianness)))
+         ((rel32/1)
+          (let ((diff (- target offset)))
+            (bytevector-s32-set! bv offset
+                                 (+ diff (linker-reloc-addend reloc))
+                                 endianness)))
          ((abs32/1)
           (bytevector-u32-set! bv offset target endianness))
          ((abs64/1)
@@ -447,7 +452,7 @@ section index."
                    (elf-section-index section))))
           objects))
 
-(define (add-elf-objects objects endianness word-size)
+(define (add-elf-objects objects endianness word-size abi type machine-type)
   "Given the list of linker objects supplied by the user, add linker
 objects corresponding to parts of the ELF file: the null object, the ELF
 header, and the section table.
@@ -485,6 +490,7 @@ list of objects, augmented with objects for the special ELF 
sections."
   ;;
   (define (make-header phnum index shoff-label)
     (let* ((header (make-elf #:byte-order endianness #:word-size word-size
+                             #:abi abi #:type type #:machine-type machine-type
                              #:phoff phoff #:phnum phnum #:phentsize phentsize
                              #:shoff 0 #:shnum shnum #:shentsize shentsize
                              #:shstrndx (or (find-shstrndx objects) 
SHN_UNDEF)))
@@ -574,7 +580,8 @@ list of objects, augmented with objects for the special ELF 
sections."
 
     (values write-segment-header! objects)))
 
-(define (allocate-elf objects page-aligned? endianness word-size)
+(define (allocate-elf objects page-aligned? endianness word-size
+                      abi type machine-type)
   "Lay out @var{objects} into an ELF image, computing the size of the
 file, the positions of the objects, and the global symbol table.
 
@@ -588,7 +595,7 @@ sections default to 8-byte alignment.
 Returns three values: the total image size, a list of objects with
 relocated headers, and the global symbol table."
   (receive (write-segment-header! objects)
-      (add-elf-objects objects endianness word-size)
+      (add-elf-objects objects endianness word-size abi type machine-type)
     (let lp ((seglists (collate-objects-into-segments objects))
              (objects '())
              (phidx 0)
@@ -646,7 +653,10 @@ section.)"
 (define* (link-elf objects #:key
                    (page-aligned? #t)
                    (endianness (target-endianness))
-                   (word-size (target-word-size)))
+                   (word-size (target-word-size))
+                   (abi ELFOSABI_STANDALONE)
+                   (type ET_DYN)
+                   (machine-type EM_NONE))
   "Create an ELF image from the linker objects, @var{objects}.
 
 If @var{page-aligned?} is true, read-only and writable data are
@@ -659,7 +669,8 @@ alignment.
 Returns a bytevector."
   (check-section-numbers objects)
   (receive (size objects symtab)
-      (allocate-elf objects page-aligned? endianness word-size)
+      (allocate-elf objects page-aligned? endianness word-size
+                    abi type machine-type)
     (let ((bv (make-bytevector size 0)))
       (for-each
        (lambda (object)


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]