aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-07-29 14:25:07 +0930
committerAlan Modra <amodra@gmail.com>2024-07-29 16:25:59 +0930
commit972092a9eda941a5744125f79fe58e52fb7007e4 (patch)
tree2d36e886297f22142cbbb4527f3ccc700c178513
parent2509e28c88f7dbb52ad3bad70e182f4146e0d339 (diff)
downloadbinutils-972092a9eda941a5744125f79fe58e52fb7007e4.zip
binutils-972092a9eda941a5744125f79fe58e52fb7007e4.tar.gz
binutils-972092a9eda941a5744125f79fe58e52fb7007e4.tar.bz2
PR32032 dwp segfaults on hello world binary
Fixing the segfault is easy with this bandaid, but further work is needed to teach dwp about DW_AT_dwo_name and dwo id in the cu header. At the moment dwp only handles DW_AT_GNU_dwo_name and DW_AT_GNU_dwo_id. PR 32032 * dwp.cc (Dwp_output_file::finalize): Return immediately on no output file.
-rw-r--r--gold/dwp.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/gold/dwp.cc b/gold/dwp.cc
index e1656d0..584892c 100644
--- a/gold/dwp.cc
+++ b/gold/dwp.cc
@@ -1838,6 +1838,9 @@ Dwp_output_file::finalize()
{
unsigned char* buf;
+ if (this->fd_ == NULL)
+ return;
+
// Write the accumulated output sections.
for (unsigned int i = 0; i < this->sections_.size(); i++)
{
@@ -1919,11 +1922,8 @@ Dwp_output_file::finalize()
this->write_ehdr();
// Close the file.
- if (this->fd_ != NULL)
- {
- if (::fclose(this->fd_) != 0)
- gold_fatal(_("%s: %s"), this->name_, strerror(errno));
- }
+ if (::fclose(this->fd_) != 0)
+ gold_fatal(_("%s: %s"), this->name_, strerror(errno));
this->fd_ = NULL;
}