Index: /branches/working-0711/ccl/library/core-files.lisp
===================================================================
--- /branches/working-0711/ccl/library/core-files.lisp	(revision 13385)
+++ /branches/working-0711/ccl/library/core-files.lisp	(revision 13386)
@@ -96,5 +96,5 @@
   (when *current-core*
     (close-core))
-  (let* ((sections (readelf-sections pathname))
+  (let* ((sections (read-sections pathname))
          (core (make-core-info :pathname pathname :sections sections)))
     (ecase method
@@ -110,5 +110,5 @@
 
 ;; Kinda stupid to call external program for this...
-(defun readelf-sections (pathname)
+(defun read-sections (pathname)
   (flet ((split (line start end)
            (loop while (setq start (position-if-not #'whitespacep line :start start :end end))
@@ -122,27 +122,36 @@
     (let* ((file (native-translated-namestring pathname))
            (string (with-output-to-string (output)
-                     (ccl:run-program "readelf" `("--sections" ,file) :output output)))
+                     #+readelf (ccl:run-program "readelf" `("--sections" "--wide" ,file) :output output)
+                     #-readelf (ccl:run-program "objdump" `("-h" "-w" ,file) :output output)))
+           (header-pos (or #+readelf (position #\[ string)
+                           #-readelf (search "Idx Name" string)
+                           (error "Cannot parse: ~%~a" string)))
            (sections (loop
-                       for start = (1+ (position #\newline string
-                                                 :start (1+ (position #\newline string
-                                                                      :start (position #\[ string)))))
-                         then next
-                       for next = (1+ (position #\newline string
-                                                :start (1+ (position #\newline string :start start))))
-                       while (eql #\space (aref string next))
+                       for start = (1+ (position #\newline string :start header-pos)) then (1+ end)
+                       for end = (or (position #\newline string :start start) (length string))
+                       while (and (< start end) (eql #\space (aref string start)))
                        nconc
-                       (destructuring-bind (number name type address filepos size &optional ent-size flags link info align)
-                           (split string start next)
-                         (assert (and (eql (char number 0) #\[) (eql (char number (1- (length number))) #\])))
-                         (setq number (read-from-string number :start 1 :end (1- (length number))))
-                         (when (eql number 0)
-                           (shiftf align info link flags ent-size size filepos address type name ""))
-                         (setq address (parse-integer address :radix 16))
-                         (setq filepos  (parse-integer filepos :radix 16))
-                         (setq size (parse-integer size :radix 16))
-                         (setq ent-size (parse-integer ent-size :radix 16))
-                         (unless (eql size 0)
-                           (assert (and (equal link "0") (equal info "0") (equal align "1")))
-                           (list (list address filepos size))))))
+                       (multiple-value-bind (name address filepos size)
+                         #+readelf
+                         (destructuring-bind (number name type address filepos size &rest flags)
+                             (split string start end)
+                           (declare (ignore flags))
+                           (assert (and (eql (char number 0) #\[) (eql (char number (1- (length number))) #\])))
+                           (setq number (read-from-string number :start 1 :end (1- (length number))))
+                           (when (eql number 0)
+                             (shiftf size filepos address type))
+                           (values name address filepos size))
+                         #-readelf
+                         (destructuring-bind (number name size address lma filepos &rest flags)
+                             (split string start end)
+                           (declare (ignore lma flags))
+                           (parse-integer number :radix 10) ;; error checking only
+                           (values name address filepos size))
+                         (unless (or (equal name "") (eql (char name 0) #\.))
+                           (setq address (parse-integer address :radix 16))
+                           (setq filepos  (parse-integer filepos :radix 16))
+                           (setq size (parse-integer size :radix 16))
+                           (unless (eql size 0)
+                             (list (list address filepos size)))))))
            (sections (cons (list most-positive-fixnum 0 0) sections));; hack for loop below
            (sections (sort sections #'< :key #'car));; sort by address
@@ -161,4 +170,5 @@
                               (setq cur-address address cur-filepos filepos cur-end (+ address size)))))))
       (coerce sections 'vector))))
+
 
 (declaim (inline core-ivector-readb core-ivector-readw core-ivector-readl core-ivector-readq
