From 42acb313be80e3d60d5c2f1de8770643cc6bb934 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 2 Feb 2006 06:50:08 +0000 Subject: Backport: 2006-02-01 Mark Mitchell * sim/ppc/emul_netbsd.c (emul_netbsd_create): Quote file-name property. * sim/ppc/emul_unix.c (emul_unix_create): Likewise. * sim/ppc/tree.c (libiberty.h): Include it. (tree_quote_property): New function. * sim/ppc/tree.h (tree_quote_property): Declare. Backport: 2006-01-23 Mark Mitchell * sim/ppc/words.h (signed32): Define as "int". (unsigned32): Define as "unsigned int". --- ChangeLog.csl | 17 +++++++++++++++++ sim/ppc/ChangeLog | 5 ----- sim/ppc/emul_netbsd.c | 5 ++++- sim/ppc/emul_unix.c | 5 ++++- sim/ppc/tree.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ sim/ppc/tree.h | 4 ++++ 6 files changed, 74 insertions(+), 7 deletions(-) diff --git a/ChangeLog.csl b/ChangeLog.csl index c2a70f6a7ba..f6482494207 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -1,3 +1,20 @@ +2006-02-01 Mark Mitchell + + Backport: + 2006-02-01 Mark Mitchell + * sim/ppc/emul_netbsd.c (emul_netbsd_create): Quote file-name property. + * sim/ppc/emul_unix.c (emul_unix_create): Likewise. + * sim/ppc/tree.c (libiberty.h): Include it. + (tree_quote_property): New function. + * sim/ppc/tree.h (tree_quote_property): Declare. + +2006-01-23 Mark Mitchell + + Backport: + 2006-01-23 Mark Mitchell + * sim/ppc/words.h (signed32): Define as "int". + (unsigned32): Define as "unsigned int". + 2006-01-26 Daniel Jacobowitz Backport: diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog index c8ce1916461..fe32804f21c 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,8 +1,3 @@ -2006-01-23 Mark Mitchell - - * words.h (signed32): Define as "int". - (unsigned32): Define as "unsigned int". - 2005-07-15 Ben Elliston * hw_htab.c (bfd_get_section_lma): Remove macro; use BFD's. diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c index 6f0fd9ec471..91c278a5950 100644 --- a/sim/ppc/emul_netbsd.c +++ b/sim/ppc/emul_netbsd.c @@ -1387,6 +1387,7 @@ emul_netbsd_create(device *root, int elf_binary; os_emul_data *bsd_data; device *vm; + char *filename; /* check that this emulation is really for us */ if (name != NULL && strcmp(name, "netbsd") != 0) @@ -1421,8 +1422,10 @@ emul_netbsd_create(device *root, (unsigned long)(top_of_stack - stack_size)); tree_parse(vm, "./nr-bytes 0x%x", stack_size); + filename = tree_quote_property (bfd_get_filename(image)); tree_parse(root, "/openprom/vm/map-binary/file-name %s", - bfd_get_filename(image)); + filename); + free (filename); /* finish the init */ tree_parse(root, "/openprom/init/register/pc 0x%lx", diff --git a/sim/ppc/emul_unix.c b/sim/ppc/emul_unix.c index 1f634350e2e..0fa5d3f7e3d 100644 --- a/sim/ppc/emul_unix.c +++ b/sim/ppc/emul_unix.c @@ -951,6 +951,7 @@ emul_unix_create(device *root, int elf_binary; os_emul_data *data; device *vm; + char *filename; /* merge any emulation specific entries into the device tree */ @@ -979,8 +980,10 @@ emul_unix_create(device *root, (unsigned long)(top_of_stack - stack_size)); tree_parse(vm, "./nr-bytes 0x%x", stack_size); + filename = tree_quote_property (bfd_get_filename(image)); tree_parse(root, "/openprom/vm/map-binary/file-name %s", - bfd_get_filename(image)); + filename); + free (filename); /* finish the init */ tree_parse(root, "/openprom/init/register/pc 0x%lx", diff --git a/sim/ppc/tree.c b/sim/ppc/tree.c index d4cfb71f0ed..4338cb0b4f6 100644 --- a/sim/ppc/tree.c +++ b/sim/ppc/tree.c @@ -45,6 +45,7 @@ #include +#include "libiberty.h" /* manipulate/lookup device names */ @@ -625,6 +626,50 @@ parse_integer_property(device *current, } } +/* PROPERTY_VALUE is a raw property value. Quote it as required by + parse_string_property. It is the caller's responsibility to free + the memory returned. */ + +EXTERN_TREE\ +(char *) +tree_quote_property(const char *property_value) +{ + char *p; + char *ret; + const char *chp; + int quotees; + + /* Count characters needing quotes in PROPERTY_VALUE. */ + quotees = 0; + for (chp = property_value; *chp; ++chp) + if (*chp == '\\' || *chp == '"') + ++quotees; + + ret = (char *) xmalloc (strlen (property_value) + + 2 /* quotes */ + + quotees + + 1 /* terminator */); + + p = ret; + /* Add the opening quote. */ + *p++ = '"'; + /* Copy the value. */ + for (chp = property_value; *chp; ++chp) + if (*chp == '\\' || *chp == '"') + { + /* Quote this character. */ + *p++ = '\\'; + *p++ = *chp; + } + else + *p++ = *chp; + /* Add the closing quote. */ + *p++ = '"'; + /* Terminate the string. */ + *p++ = '\0'; + + return ret; +} /* ... */ diff --git a/sim/ppc/tree.h b/sim/ppc/tree.h index 46590cb6266..2ed7fd0bbf5 100644 --- a/sim/ppc/tree.h +++ b/sim/ppc/tree.h @@ -41,6 +41,10 @@ */ +EXTERN_TREE\ +(char*) tree_quote_property +(const char *property_value); + EXTERN_TREE\ (device *) tree_parse (device *root, -- cgit v1.2.1