| 1 |
|
| 2 |
@example |
| 3 |
/* Set to N to open the next N BFDs using an alternate id space. */ |
| 4 |
extern unsigned int bfd_use_reserved_id; |
| 5 |
@end example |
| 6 |
@section Opening and closing BFDs |
| 7 |
|
| 8 |
|
| 9 |
@subsection Functions for opening and closing |
| 10 |
|
| 11 |
|
| 12 |
@findex bfd_fopen |
| 13 |
@subsubsection @code{bfd_fopen} |
| 14 |
@strong{Synopsis} |
| 15 |
@example |
| 16 |
bfd *bfd_fopen (const char *filename, const char *target, |
| 17 |
const char *mode, int fd); |
| 18 |
@end example |
| 19 |
@strong{Description}@* |
| 20 |
Open the file @var{filename} with the target @var{target}. |
| 21 |
Return a pointer to the created BFD. If @var{fd} is not -1, |
| 22 |
then @code{fdopen} is used to open the file; otherwise, @code{fopen} |
| 23 |
is used. @var{mode} is passed directly to @code{fopen} or |
| 24 |
@code{fdopen}. |
| 25 |
|
| 26 |
Calls @code{bfd_find_target}, so @var{target} is interpreted as by |
| 27 |
that function. |
| 28 |
|
| 29 |
The new BFD is marked as cacheable iff @var{fd} is -1. |
| 30 |
|
| 31 |
If @code{NULL} is returned then an error has occured. Possible errors |
| 32 |
are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or |
| 33 |
@code{system_call} error. |
| 34 |
|
| 35 |
On error, @var{fd} is always closed. |
| 36 |
|
| 37 |
A copy of the @var{filename} argument is stored in the newly created |
| 38 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 39 |
|
| 40 |
@findex bfd_openr |
| 41 |
@subsubsection @code{bfd_openr} |
| 42 |
@strong{Synopsis} |
| 43 |
@example |
| 44 |
bfd *bfd_openr (const char *filename, const char *target); |
| 45 |
@end example |
| 46 |
@strong{Description}@* |
| 47 |
Open the file @var{filename} (using @code{fopen}) with the target |
| 48 |
@var{target}. Return a pointer to the created BFD. |
| 49 |
|
| 50 |
Calls @code{bfd_find_target}, so @var{target} is interpreted as by |
| 51 |
that function. |
| 52 |
|
| 53 |
If @code{NULL} is returned then an error has occured. Possible errors |
| 54 |
are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or |
| 55 |
@code{system_call} error. |
| 56 |
|
| 57 |
A copy of the @var{filename} argument is stored in the newly created |
| 58 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 59 |
|
| 60 |
@findex bfd_fdopenr |
| 61 |
@subsubsection @code{bfd_fdopenr} |
| 62 |
@strong{Synopsis} |
| 63 |
@example |
| 64 |
bfd *bfd_fdopenr (const char *filename, const char *target, int fd); |
| 65 |
@end example |
| 66 |
@strong{Description}@* |
| 67 |
@code{bfd_fdopenr} is to @code{bfd_fopenr} much like @code{fdopen} is to |
| 68 |
@code{fopen}. It opens a BFD on a file already described by the |
| 69 |
@var{fd} supplied. |
| 70 |
|
| 71 |
When the file is later @code{bfd_close}d, the file descriptor will |
| 72 |
be closed. If the caller desires that this file descriptor be |
| 73 |
cached by BFD (opened as needed, closed as needed to free |
| 74 |
descriptors for other opens), with the supplied @var{fd} used as |
| 75 |
an initial file descriptor (but subject to closure at any time), |
| 76 |
call bfd_set_cacheable(bfd, 1) on the returned BFD. The default |
| 77 |
is to assume no caching; the file descriptor will remain open |
| 78 |
until @code{bfd_close}, and will not be affected by BFD operations |
| 79 |
on other files. |
| 80 |
|
| 81 |
Possible errors are @code{bfd_error_no_memory}, |
| 82 |
@code{bfd_error_invalid_target} and @code{bfd_error_system_call}. |
| 83 |
|
| 84 |
On error, @var{fd} is closed. |
| 85 |
|
| 86 |
A copy of the @var{filename} argument is stored in the newly created |
| 87 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 88 |
|
| 89 |
@findex bfd_openstreamr |
| 90 |
@subsubsection @code{bfd_openstreamr} |
| 91 |
@strong{Synopsis} |
| 92 |
@example |
| 93 |
bfd *bfd_openstreamr (const char * filename, const char * target, |
| 94 |
void * stream); |
| 95 |
@end example |
| 96 |
@strong{Description}@* |
| 97 |
Open a BFD for read access on an existing stdio stream. When |
| 98 |
the BFD is passed to @code{bfd_close}, the stream will be closed. |
| 99 |
|
| 100 |
A copy of the @var{filename} argument is stored in the newly created |
| 101 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 102 |
|
| 103 |
@findex bfd_openr_iovec |
| 104 |
@subsubsection @code{bfd_openr_iovec} |
| 105 |
@strong{Synopsis} |
| 106 |
@example |
| 107 |
bfd *bfd_openr_iovec (const char *filename, const char *target, |
| 108 |
void *(*open_func) (struct bfd *nbfd, |
| 109 |
void *open_closure), |
| 110 |
void *open_closure, |
| 111 |
file_ptr (*pread_func) (struct bfd *nbfd, |
| 112 |
void *stream, |
| 113 |
void *buf, |
| 114 |
file_ptr nbytes, |
| 115 |
file_ptr offset), |
| 116 |
int (*close_func) (struct bfd *nbfd, |
| 117 |
void *stream), |
| 118 |
int (*stat_func) (struct bfd *abfd, |
| 119 |
void *stream, |
| 120 |
struct stat *sb)); |
| 121 |
@end example |
| 122 |
@strong{Description}@* |
| 123 |
Create and return a BFD backed by a read-only @var{stream}. |
| 124 |
The @var{stream} is created using @var{open_func}, accessed using |
| 125 |
@var{pread_func} and destroyed using @var{close_func}. |
| 126 |
|
| 127 |
Calls @code{bfd_find_target}, so @var{target} is interpreted as by |
| 128 |
that function. |
| 129 |
|
| 130 |
Calls @var{open_func} (which can call @code{bfd_zalloc} and |
| 131 |
@code{bfd_get_filename}) to obtain the read-only stream backing |
| 132 |
the BFD. @var{open_func} either succeeds returning the |
| 133 |
non-@code{NULL} @var{stream}, or fails returning @code{NULL} |
| 134 |
(setting @code{bfd_error}). |
| 135 |
|
| 136 |
Calls @var{pread_func} to request @var{nbytes} of data from |
| 137 |
@var{stream} starting at @var{offset} (e.g., via a call to |
| 138 |
@code{bfd_read}). @var{pread_func} either succeeds returning the |
| 139 |
number of bytes read (which can be less than @var{nbytes} when |
| 140 |
end-of-file), or fails returning -1 (setting @code{bfd_error}). |
| 141 |
|
| 142 |
Calls @var{close_func} when the BFD is later closed using |
| 143 |
@code{bfd_close}. @var{close_func} either succeeds returning 0, or |
| 144 |
fails returning -1 (setting @code{bfd_error}). |
| 145 |
|
| 146 |
Calls @var{stat_func} to fill in a stat structure for bfd_stat, |
| 147 |
bfd_get_size, and bfd_get_mtime calls. @var{stat_func} returns 0 |
| 148 |
on success, or returns -1 on failure (setting @code{bfd_error}). |
| 149 |
|
| 150 |
If @code{bfd_openr_iovec} returns @code{NULL} then an error has |
| 151 |
occurred. Possible errors are @code{bfd_error_no_memory}, |
| 152 |
@code{bfd_error_invalid_target} and @code{bfd_error_system_call}. |
| 153 |
|
| 154 |
A copy of the @var{filename} argument is stored in the newly created |
| 155 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 156 |
|
| 157 |
@findex bfd_openw |
| 158 |
@subsubsection @code{bfd_openw} |
| 159 |
@strong{Synopsis} |
| 160 |
@example |
| 161 |
bfd *bfd_openw (const char *filename, const char *target); |
| 162 |
@end example |
| 163 |
@strong{Description}@* |
| 164 |
Create a BFD, associated with file @var{filename}, using the |
| 165 |
file format @var{target}, and return a pointer to it. |
| 166 |
|
| 167 |
Possible errors are @code{bfd_error_system_call}, @code{bfd_error_no_memory}, |
| 168 |
@code{bfd_error_invalid_target}. |
| 169 |
|
| 170 |
A copy of the @var{filename} argument is stored in the newly created |
| 171 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 172 |
|
| 173 |
@findex bfd_close |
| 174 |
@subsubsection @code{bfd_close} |
| 175 |
@strong{Synopsis} |
| 176 |
@example |
| 177 |
bfd_boolean bfd_close (bfd *abfd); |
| 178 |
@end example |
| 179 |
@strong{Description}@* |
| 180 |
Close a BFD. If the BFD was open for writing, then pending |
| 181 |
operations are completed and the file written out and closed. |
| 182 |
If the created file is executable, then @code{chmod} is called |
| 183 |
to mark it as such. |
| 184 |
|
| 185 |
All memory attached to the BFD is released. |
| 186 |
|
| 187 |
The file descriptor associated with the BFD is closed (even |
| 188 |
if it was passed in to BFD by @code{bfd_fdopenr}). |
| 189 |
|
| 190 |
@strong{Returns}@* |
| 191 |
@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. |
| 192 |
|
| 193 |
@findex bfd_close_all_done |
| 194 |
@subsubsection @code{bfd_close_all_done} |
| 195 |
@strong{Synopsis} |
| 196 |
@example |
| 197 |
bfd_boolean bfd_close_all_done (bfd *); |
| 198 |
@end example |
| 199 |
@strong{Description}@* |
| 200 |
Close a BFD. Differs from @code{bfd_close} since it does not |
| 201 |
complete any pending operations. This routine would be used |
| 202 |
if the application had just used BFD for swapping and didn't |
| 203 |
want to use any of the writing code. |
| 204 |
|
| 205 |
If the created file is executable, then @code{chmod} is called |
| 206 |
to mark it as such. |
| 207 |
|
| 208 |
All memory attached to the BFD is released. |
| 209 |
|
| 210 |
@strong{Returns}@* |
| 211 |
@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. |
| 212 |
|
| 213 |
@findex bfd_create |
| 214 |
@subsubsection @code{bfd_create} |
| 215 |
@strong{Synopsis} |
| 216 |
@example |
| 217 |
bfd *bfd_create (const char *filename, bfd *templ); |
| 218 |
@end example |
| 219 |
@strong{Description}@* |
| 220 |
Create a new BFD in the manner of @code{bfd_openw}, but without |
| 221 |
opening a file. The new BFD takes the target from the target |
| 222 |
used by @var{templ}. The format is always set to @code{bfd_object}. |
| 223 |
|
| 224 |
A copy of the @var{filename} argument is stored in the newly created |
| 225 |
BFD. It can be accessed via the bfd_get_filename() macro. |
| 226 |
|
| 227 |
@findex bfd_make_writable |
| 228 |
@subsubsection @code{bfd_make_writable} |
| 229 |
@strong{Synopsis} |
| 230 |
@example |
| 231 |
bfd_boolean bfd_make_writable (bfd *abfd); |
| 232 |
@end example |
| 233 |
@strong{Description}@* |
| 234 |
Takes a BFD as created by @code{bfd_create} and converts it |
| 235 |
into one like as returned by @code{bfd_openw}. It does this |
| 236 |
by converting the BFD to BFD_IN_MEMORY. It's assumed that |
| 237 |
you will call @code{bfd_make_readable} on this bfd later. |
| 238 |
|
| 239 |
@strong{Returns}@* |
| 240 |
@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. |
| 241 |
|
| 242 |
@findex bfd_make_readable |
| 243 |
@subsubsection @code{bfd_make_readable} |
| 244 |
@strong{Synopsis} |
| 245 |
@example |
| 246 |
bfd_boolean bfd_make_readable (bfd *abfd); |
| 247 |
@end example |
| 248 |
@strong{Description}@* |
| 249 |
Takes a BFD as created by @code{bfd_create} and |
| 250 |
@code{bfd_make_writable} and converts it into one like as |
| 251 |
returned by @code{bfd_openr}. It does this by writing the |
| 252 |
contents out to the memory buffer, then reversing the |
| 253 |
direction. |
| 254 |
|
| 255 |
@strong{Returns}@* |
| 256 |
@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. |
| 257 |
|
| 258 |
@findex bfd_alloc |
| 259 |
@subsubsection @code{bfd_alloc} |
| 260 |
@strong{Synopsis} |
| 261 |
@example |
| 262 |
void *bfd_alloc (bfd *abfd, bfd_size_type wanted); |
| 263 |
@end example |
| 264 |
@strong{Description}@* |
| 265 |
Allocate a block of @var{wanted} bytes of memory attached to |
| 266 |
@code{abfd} and return a pointer to it. |
| 267 |
|
| 268 |
@findex bfd_zalloc |
| 269 |
@subsubsection @code{bfd_zalloc} |
| 270 |
@strong{Synopsis} |
| 271 |
@example |
| 272 |
void *bfd_zalloc (bfd *abfd, bfd_size_type wanted); |
| 273 |
@end example |
| 274 |
@strong{Description}@* |
| 275 |
Allocate a block of @var{wanted} bytes of zeroed memory |
| 276 |
attached to @code{abfd} and return a pointer to it. |
| 277 |
|
| 278 |
@findex bfd_calc_gnu_debuglink_crc32 |
| 279 |
@subsubsection @code{bfd_calc_gnu_debuglink_crc32} |
| 280 |
@strong{Synopsis} |
| 281 |
@example |
| 282 |
unsigned long bfd_calc_gnu_debuglink_crc32 |
| 283 |
(unsigned long crc, const unsigned char *buf, bfd_size_type len); |
| 284 |
@end example |
| 285 |
@strong{Description}@* |
| 286 |
Computes a CRC value as used in the .gnu_debuglink section. |
| 287 |
Advances the previously computed @var{crc} value by computing |
| 288 |
and adding in the crc32 for @var{len} bytes of @var{buf}. |
| 289 |
|
| 290 |
@strong{Returns}@* |
| 291 |
Return the updated CRC32 value. |
| 292 |
|
| 293 |
@findex bfd_get_debug_link_info_1 |
| 294 |
@subsubsection @code{bfd_get_debug_link_info_1} |
| 295 |
@strong{Synopsis} |
| 296 |
@example |
| 297 |
char *bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out); |
| 298 |
@end example |
| 299 |
@strong{Description}@* |
| 300 |
Extracts the filename and CRC32 value for any separate debug |
| 301 |
information file associated with @var{abfd}. |
| 302 |
|
| 303 |
The @var{crc32_out} parameter is an untyped pointer because |
| 304 |
this routine is used as a @code{get_func_type} function, but it |
| 305 |
is expected to be an unsigned long pointer. |
| 306 |
|
| 307 |
@strong{Returns}@* |
| 308 |
The filename of the associated debug information file, or NULL |
| 309 |
if there is no such file. If the filename was found then the |
| 310 |
contents of @var{crc32_out} are updated to hold the corresponding |
| 311 |
CRC32 value for the file. |
| 312 |
|
| 313 |
The returned filename is allocated with @code{malloc}; freeing |
| 314 |
it is the responsibility of the caller. |
| 315 |
|
| 316 |
@findex bfd_get_debug_link_info |
| 317 |
@subsubsection @code{bfd_get_debug_link_info} |
| 318 |
@strong{Synopsis} |
| 319 |
@example |
| 320 |
char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
| 321 |
@end example |
| 322 |
@strong{Description}@* |
| 323 |
Extracts the filename and CRC32 value for any separate debug |
| 324 |
information file associated with @var{abfd}. |
| 325 |
|
| 326 |
@strong{Returns}@* |
| 327 |
The filename of the associated debug information file, or NULL |
| 328 |
if there is no such file. If the filename was found then the |
| 329 |
contents of @var{crc32_out} are updated to hold the corresponding |
| 330 |
CRC32 value for the file. |
| 331 |
|
| 332 |
The returned filename is allocated with @code{malloc}; freeing |
| 333 |
it is the responsibility of the caller. |
| 334 |
|
| 335 |
@findex bfd_get_alt_debug_link_info |
| 336 |
@subsubsection @code{bfd_get_alt_debug_link_info} |
| 337 |
@strong{Synopsis} |
| 338 |
@example |
| 339 |
char *bfd_get_alt_debug_link_info (bfd * abfd, |
| 340 |
bfd_size_type *buildid_len, |
| 341 |
bfd_byte **buildid_out); |
| 342 |
@end example |
| 343 |
@strong{Description}@* |
| 344 |
Fetch the filename and BuildID value for any alternate debuginfo |
| 345 |
associated with @var{abfd}. Return NULL if no such info found, |
| 346 |
otherwise return filename and update @var{buildid_len} and |
| 347 |
@var{buildid_out}. The returned filename and build_id are |
| 348 |
allocated with @code{malloc}; freeing them is the responsibility |
| 349 |
of the caller. |
| 350 |
|
| 351 |
@findex separate_debug_file_exists |
| 352 |
@subsubsection @code{separate_debug_file_exists} |
| 353 |
@strong{Synopsis} |
| 354 |
@example |
| 355 |
bfd_boolean separate_debug_file_exists |
| 356 |
(char *name, void *crc32_p); |
| 357 |
@end example |
| 358 |
@strong{Description}@* |
| 359 |
Checks to see if @var{name} is a file and if its contents |
| 360 |
match @var{crc32}, which is a pointer to an @code{unsigned |
| 361 |
long} containing a CRC32. |
| 362 |
|
| 363 |
The @var{crc32_p} parameter is an untyped pointer because |
| 364 |
this routine is used as a @code{check_func_type} function. |
| 365 |
|
| 366 |
@findex separate_alt_debug_file_exists |
| 367 |
@subsubsection @code{separate_alt_debug_file_exists} |
| 368 |
@strong{Synopsis} |
| 369 |
@example |
| 370 |
bfd_boolean separate_alt_debug_file_exists |
| 371 |
(char *name, void *unused); |
| 372 |
@end example |
| 373 |
@strong{Description}@* |
| 374 |
Checks to see if @var{name} is a file. |
| 375 |
|
| 376 |
@findex find_separate_debug_file |
| 377 |
@subsubsection @code{find_separate_debug_file} |
| 378 |
@strong{Synopsis} |
| 379 |
@example |
| 380 |
char *find_separate_debug_file |
| 381 |
(bfd *abfd, const char *dir, bfd_boolean include_dirs, |
| 382 |
get_func_type get, check_func_type check, void *data); |
| 383 |
@end example |
| 384 |
@strong{Description}@* |
| 385 |
Searches for a debug information file corresponding to @var{abfd}. |
| 386 |
|
| 387 |
The name of the separate debug info file is returned by the |
| 388 |
@var{get} function. This function scans various fixed locations |
| 389 |
in the filesystem, including the file tree rooted at @var{dir}. |
| 390 |
If the @var{include_dirs} parameter is true then the directory |
| 391 |
components of @var{abfd}'s filename will be included in the |
| 392 |
searched locations. |
| 393 |
|
| 394 |
@var{data} is passed unmodified to the @var{get} and @var{check} |
| 395 |
functions. It is generally used to implement build-id-like |
| 396 |
matching in the callback functions. |
| 397 |
|
| 398 |
@strong{Returns}@* |
| 399 |
Returns the filename of the first file to be found which |
| 400 |
receives a TRUE result from the @var{check} function. |
| 401 |
Returns NULL if no valid file could be found. |
| 402 |
|
| 403 |
@findex bfd_follow_gnu_debuglink |
| 404 |
@subsubsection @code{bfd_follow_gnu_debuglink} |
| 405 |
@strong{Synopsis} |
| 406 |
@example |
| 407 |
char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); |
| 408 |
@end example |
| 409 |
@strong{Description}@* |
| 410 |
Takes a BFD and searches it for a .gnu_debuglink section. If this |
| 411 |
section is found, it examines the section for the name and checksum |
| 412 |
of a '.debug' file containing auxiliary debugging information. It |
| 413 |
then searches the filesystem for this .debug file in some standard |
| 414 |
locations, including the directory tree rooted at @var{dir}, and if |
| 415 |
found returns the full filename. |
| 416 |
|
| 417 |
If @var{dir} is NULL, the search will take place starting at |
| 418 |
the current directory. |
| 419 |
|
| 420 |
@strong{Returns}@* |
| 421 |
@code{NULL} on any errors or failure to locate the .debug file, |
| 422 |
otherwise a pointer to a heap-allocated string containing the |
| 423 |
filename. The caller is responsible for freeing this string. |
| 424 |
|
| 425 |
@findex bfd_follow_gnu_debugaltlink |
| 426 |
@subsubsection @code{bfd_follow_gnu_debugaltlink} |
| 427 |
@strong{Synopsis} |
| 428 |
@example |
| 429 |
char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir); |
| 430 |
@end example |
| 431 |
@strong{Description}@* |
| 432 |
Takes a BFD and searches it for a .gnu_debugaltlink section. If this |
| 433 |
section is found, it examines the section for the name of a file |
| 434 |
containing auxiliary debugging information. It then searches the |
| 435 |
filesystem for this file in a set of standard locations, including |
| 436 |
the directory tree rooted at @var{dir}, and if found returns the |
| 437 |
full filename. |
| 438 |
|
| 439 |
If @var{dir} is NULL, the search will take place starting at |
| 440 |
the current directory. |
| 441 |
|
| 442 |
@strong{Returns}@* |
| 443 |
@code{NULL} on any errors or failure to locate the debug file, |
| 444 |
otherwise a pointer to a heap-allocated string containing the |
| 445 |
filename. The caller is responsible for freeing this string. |
| 446 |
|
| 447 |
@findex bfd_create_gnu_debuglink_section |
| 448 |
@subsubsection @code{bfd_create_gnu_debuglink_section} |
| 449 |
@strong{Synopsis} |
| 450 |
@example |
| 451 |
struct bfd_section *bfd_create_gnu_debuglink_section |
| 452 |
(bfd *abfd, const char *filename); |
| 453 |
@end example |
| 454 |
@strong{Description}@* |
| 455 |
Takes a @var{BFD} and adds a .gnu_debuglink section to it. The |
| 456 |
section is sized to be big enough to contain a link to the specified |
| 457 |
@var{filename}. |
| 458 |
|
| 459 |
@strong{Returns}@* |
| 460 |
A pointer to the new section is returned if all is ok. Otherwise |
| 461 |
@code{NULL} is returned and bfd_error is set. |
| 462 |
|
| 463 |
@findex bfd_fill_in_gnu_debuglink_section |
| 464 |
@subsubsection @code{bfd_fill_in_gnu_debuglink_section} |
| 465 |
@strong{Synopsis} |
| 466 |
@example |
| 467 |
bfd_boolean bfd_fill_in_gnu_debuglink_section |
| 468 |
(bfd *abfd, struct bfd_section *sect, const char *filename); |
| 469 |
@end example |
| 470 |
@strong{Description}@* |
| 471 |
Takes a @var{BFD} and containing a .gnu_debuglink section @var{SECT} |
| 472 |
and fills in the contents of the section to contain a link to the |
| 473 |
specified @var{filename}. The filename should be relative to the |
| 474 |
current directory. |
| 475 |
|
| 476 |
@strong{Returns}@* |
| 477 |
@code{TRUE} is returned if all is ok. Otherwise @code{FALSE} is returned |
| 478 |
and bfd_error is set. |
| 479 |
|
| 480 |
@findex get_build_id |
| 481 |
@subsubsection @code{get_build_id} |
| 482 |
@strong{Synopsis} |
| 483 |
@example |
| 484 |
struct bfd_build_id * get_build_id (bfd *abfd); |
| 485 |
@end example |
| 486 |
@strong{Description}@* |
| 487 |
Finds the build-id associated with @var{abfd}. If the build-id is |
| 488 |
extracted from the note section then a build-id structure is built |
| 489 |
for it, using memory allocated to @var{abfd}, and this is then |
| 490 |
attached to the @var{abfd}. |
| 491 |
|
| 492 |
@strong{Returns}@* |
| 493 |
Returns a pointer to the build-id structure if a build-id could be |
| 494 |
found. If no build-id is found NULL is returned and error code is |
| 495 |
set. |
| 496 |
|
| 497 |
@findex get_build_id_name |
| 498 |
@subsubsection @code{get_build_id_name} |
| 499 |
@strong{Synopsis} |
| 500 |
@example |
| 501 |
char * get_build_id_name (bfd *abfd, void *build_id_out_p) |
| 502 |
@end example |
| 503 |
@strong{Description}@* |
| 504 |
Searches @var{abfd} for a build-id, and then constructs a pathname |
| 505 |
from it. The path is computed as .build-id/NN/NN+NN.debug where |
| 506 |
NNNN+NN is the build-id value as a hexadecimal string. |
| 507 |
|
| 508 |
@strong{Returns}@* |
| 509 |
Returns the constructed filename or NULL upon error. |
| 510 |
It is the caller's responsibility to free the memory used to hold the |
| 511 |
filename. |
| 512 |
If a filename is returned then the @var{build_id_out_p} |
| 513 |
parameter (which points to a @code{struct bfd_build_id} |
| 514 |
pointer) is set to a pointer to the build_id structure. |
| 515 |
|
| 516 |
@findex check_build_id_file |
| 517 |
@subsubsection @code{check_build_id_file} |
| 518 |
@strong{Synopsis} |
| 519 |
@example |
| 520 |
bfd_boolean check_build_id_file (char *name, void *buildid_p); |
| 521 |
@end example |
| 522 |
@strong{Description}@* |
| 523 |
Checks to see if @var{name} is a readable file and if its build-id |
| 524 |
matches @var{buildid}. |
| 525 |
|
| 526 |
@strong{Returns}@* |
| 527 |
Returns TRUE if the file exists, is readable, and contains a |
| 528 |
build-id which matches the build-id pointed at by |
| 529 |
@var{build_id_p} (which is really a @code{struct bfd_build_id **}). |
| 530 |
|
| 531 |
@findex bfd_follow_build_id_debuglink |
| 532 |
@subsubsection @code{bfd_follow_build_id_debuglink} |
| 533 |
@strong{Synopsis} |
| 534 |
@example |
| 535 |
char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir); |
| 536 |
@end example |
| 537 |
@strong{Description}@* |
| 538 |
Takes @var{abfd} and searches it for a .note.gnu.build-id section. |
| 539 |
If this section is found, it extracts the value of the NT_GNU_BUILD_ID |
| 540 |
note, which should be a hexadecimal value @var{NNNN+NN} (for |
| 541 |
32+ hex digits). It then searches the filesystem for a file named |
| 542 |
@var{.build-id/NN/NN+NN.debug} in a set of standard locations, |
| 543 |
including the directory tree rooted at @var{dir}. The filename |
| 544 |
of the first matching file to be found is returned. A matching |
| 545 |
file should contain a .note.gnu.build-id section with the same |
| 546 |
@var{NNNN+NN} note as @var{abfd}, although this check is currently |
| 547 |
not implemented. |
| 548 |
|
| 549 |
If @var{dir} is NULL, the search will take place starting at |
| 550 |
the current directory. |
| 551 |
|
| 552 |
@strong{Returns}@* |
| 553 |
@code{NULL} on any errors or failure to locate the debug file, |
| 554 |
otherwise a pointer to a heap-allocated string containing the |
| 555 |
filename. The caller is responsible for freeing this string. |
| 556 |
|
| 557 |
@findex bfd_set_filename |
| 558 |
@subsubsection @code{bfd_set_filename} |
| 559 |
@strong{Synopsis} |
| 560 |
@example |
| 561 |
const char *bfd_set_filename (bfd *abfd, const char *filename); |
| 562 |
@end example |
| 563 |
@strong{Description}@* |
| 564 |
Set the filename of @var{abfd}, copying the FILENAME parameter to |
| 565 |
bfd_alloc'd memory owned by @var{abfd}. Returns a pointer the |
| 566 |
newly allocated name, or NULL if the allocation failed. |
| 567 |
|