GNU Binutils with patches for OS216
修訂 | f8773be1be076f828b93ac3bebeab3f782e191e4 (tree) |
---|---|
時間 | 2015-06-25 17:54:12 |
作者 | Gary Benson <gbenson@redh...> |
Commiter | Gary Benson |
Correctly notice empty sysroots in solib_find_1
Some parts of solib_find_1 should only operate if the sysroot
is nonempty after processing, but the logic that checked this
happened before trailing slashes were stripped so empty but
non-NULL sysroots were possible. This commit moves the logic
so it correctly notices all empty sysroots.
gdb/ChangeLog:
* solib.c (solib_find_1): Set local variable sysroot to NULL if
it is the empty string after trailing slashes have been stripped.
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-06-25 Gary Benson <gbenson@redhat.com> |
2 | 2 | |
3 | + * solib.c (solib_find_1): Set local variable sysroot to NULL if | |
4 | + it is the empty string after trailing slashes have been stripped. | |
5 | + | |
6 | +2015-06-25 Gary Benson <gbenson@redhat.com> | |
7 | + | |
3 | 8 | * exec.c (exec_file_locate_attach): Remove gdb_sysroot NULL check. |
4 | 9 | * infrun.c (follow_exec): Likewise. |
5 | 10 | * remote.c (remote_filesystem_is_local): Likewise. |
@@ -158,6 +158,7 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib) | ||
158 | 158 | const char *fskind = effective_target_file_system_kind (); |
159 | 159 | struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); |
160 | 160 | char *sysroot = gdb_sysroot; |
161 | + int prefix_len, orig_prefix_len; | |
161 | 162 | |
162 | 163 | /* If the absolute prefix starts with "target:" but the filesystem |
163 | 164 | accessed by the target_fileio_* methods is the local filesystem |
@@ -168,17 +169,16 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib) | ||
168 | 169 | if (is_target_filename (sysroot) && target_filesystem_is_local ()) |
169 | 170 | sysroot += strlen (TARGET_SYSROOT_PREFIX); |
170 | 171 | |
171 | - if (*sysroot == '\0') | |
172 | - sysroot = NULL; | |
173 | - else | |
174 | - { | |
175 | - int prefix_len = strlen (sysroot); | |
172 | + /* Strip any trailing slashes from the absolute prefix. */ | |
173 | + prefix_len = orig_prefix_len = strlen (sysroot); | |
176 | 174 | |
177 | - /* Remove trailing slashes from absolute prefix. */ | |
178 | - while (prefix_len > 0 | |
179 | - && IS_DIR_SEPARATOR (sysroot[prefix_len - 1])) | |
180 | - prefix_len--; | |
175 | + while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1])) | |
176 | + prefix_len--; | |
181 | 177 | |
178 | + if (prefix_len == 0) | |
179 | + sysroot = NULL; | |
180 | + else if (prefix_len != orig_prefix_len) | |
181 | + { | |
182 | 182 | sysroot = savestring (sysroot, prefix_len); |
183 | 183 | make_cleanup (xfree, sysroot); |
184 | 184 | } |