You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/11/23 08:18:40 UTC

[GitHub] andrzej-kaczmarek closed pull request #96: newt: Workaound incorrectly resolved symbols in 'newt size'

andrzej-kaczmarek closed pull request #96: newt: Workaound incorrectly resolved symbols in 'newt size'
URL: https://github.com/apache/mynewt-newt/pull/96
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/builder/size_report.go b/newt/builder/size_report.go
index 5c9fa02..ebe8063 100644
--- a/newt/builder/size_report.go
+++ b/newt/builder/size_report.go
@@ -35,7 +35,7 @@ func runNmCommand(elfFilePath string) ([]byte, error) {
 		err    error
 	)
 	cmdName := "arm-none-eabi-nm"
-	cmdArgs := []string{elfFilePath, "-S", "-l", "--size-sort", "--radix=d"}
+	cmdArgs := []string{elfFilePath, "-S", "-l", "--size-sort"}
 
 	if cmdOut, err = exec.Command(cmdName, cmdArgs...).Output(); err != nil {
 		fmt.Fprintln(os.Stderr, "There was an error running nm command: ", err)
@@ -61,6 +61,22 @@ func runObjdumpCommand(elfFilePath string, params string) ([]byte, error) {
 	return cmdOut, err
 }
 
+func runAddr2lineCommand(elfFilePath string, address string) ([]byte, error) {
+	var (
+		cmdOut []byte
+		err    error
+	)
+	cmdName := "arm-none-eabi-addr2line"
+	cmdArgs := []string{"-e", elfFilePath, address}
+
+	cmdOut, err = exec.Command(cmdName, cmdArgs...).Output()
+
+	/* This can fail and it's not a critical error */
+
+	return cmdOut, err
+}
+
+
 func loadSymbolsAndPaths(elfFilePath, pathToStrip string) (map[string]string,
 	error) {
 	symbolsPath := make(map[string]string)
@@ -80,7 +96,13 @@ func loadSymbolsAndPaths(elfFilePath, pathToStrip string) (map[string]string,
 		var path string
 
 		if len(fields) < 5 {
-			path = "(other)"
+			addr2lineOut, err := runAddr2lineCommand(elfFilePath, fields[0])
+			if err != nil {
+				path = "(other)"
+			} else {
+				aline := strings.Split(string(addr2lineOut), "\n")[0]
+				path = strings.Split(aline, ":")[0]
+			}
 		} else {
 			path = strings.Split(fields[4], ":")[0]
 		}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services