diff options
author | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-11 18:59:42 +0000 |
---|---|---|
committer | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-11 18:59:42 +0000 |
commit | 5a121a91b991c1b244cd6ded463a3535cc85b119 (patch) | |
tree | a156ad6f58e7cde9a778abfc8c47a4b0604b9243 /gcc/config/darwin.c | |
parent | 03033f8f9262af21af5fbc20c718b1cbc4ef3ae7 (diff) | |
download | gcc-5a121a91b991c1b244cd6ded463a3535cc85b119.tar.gz |
* darwin.c (darwin_encode_section_info): Rewrite to simplify
and fix coding mistakes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43200 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r-- | gcc/config/darwin.c | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 509ff91262a..37715796cb0 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1001,6 +1001,9 @@ darwin_encode_section_info (decl) { char code = '\0'; int defined = 0; + rtx sym_ref; + char *orig_str, *new_str; + size_t len, new_len; if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) @@ -1014,30 +1017,38 @@ darwin_encode_section_info (decl) else if (TREE_CODE (decl) == VAR_DECL) code = (defined ? 'D' : 'd'); - if (code != '\0') - { - rtx sym_ref = XEXP (DECL_RTL (decl), 0); - - if (*(XSTR (sym_ref, 0)) == '!') - { - (XSTR(sym_ref, 0))[1] = code; - update_non_lazy_ptrs (XSTR (sym_ref, 0)); - return; - } - - { - size_t len = strlen (XSTR (sym_ref, 0)); - size_t newlen = len + 4; - char *str = alloca (newlen); + if (code == '\0') + return; - str[0] = '!'; - str[1] = code; - str[2] = '_'; - str[3] = '_'; - memcpy (str + 4, XSTR (sym_ref, 0), len + 1); + sym_ref = XEXP (DECL_RTL (decl), 0); + orig_str = XSTR (sym_ref, 0); + len = strlen (orig_str) + 1; - XSTR (sym_ref, 0) = ggc_alloc_string (str, newlen); - } + if (orig_str[0] == '!') + { + /* Already encoded; see if we need to change it. */ + if (code == orig_str[1]) + return; + /* Yes, tweak a copy of the name and put it in a new string. */ + new_str = alloca (len); + memcpy (new_str, orig_str, len); + new_str[1] = code; + XSTR (sym_ref, 0) = ggc_alloc_string (new_str, len); + /* The non-lazy pointer list may have captured references to the + old encoded name, change them. */ + update_non_lazy_ptrs (XSTR (sym_ref, 0)); + } + else + { + /* Add the encoding. */ + new_len = len + 4; + new_str = alloca (new_len); + new_str[0] = '!'; + new_str[1] = code; + new_str[2] = '_'; + new_str[3] = '_'; + memcpy (new_str + 4, orig_str, len); + XSTR (sym_ref, 0) = ggc_alloc_string (new_str, new_len); } } |