aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2015-06-02 09:45:24 -0700
committerCary Coutant <ccoutant@gmail.com>2015-06-02 09:46:10 -0700
commit9c7fe3c5c2c9e4c3571c253cf77341e3f6adf94c (patch)
treebba32f88e9ab805357e10aa203897e3cbb4e9853 /gold/layout.h
parentafa403d8d467466edfd77baea0bba7ae45a4447f (diff)
downloadgdb-9c7fe3c5c2c9e4c3571c253cf77341e3f6adf94c.zip
gdb-9c7fe3c5c2c9e4c3571c253cf77341e3f6adf94c.tar.gz
gdb-9c7fe3c5c2c9e4c3571c253cf77341e3f6adf94c.tar.bz2
PR 17819: Fix --build-id=tree when using --compress-debug-sections.
When --build-id=tree is selected, gold would schedule a set of tasks to run to compute md5 hashes in parallel on chunks of the file. The scheduling was done before the Write_after_input_sections_task ran, so if we are compressing debug sections, the output file will change size and be remapped to a new address, sometimes causing the build id computation to crash, but even when it doesn't crash, it wouldn't include the debug information in the hash computation. This patch delays the scheduling of the md5 tasks until after Write_after_input_sections_task. gold/ PR gold/17819 * gold.cc (queue_final_tasks): When --build-id=tree, queue a separate task to schedule the build id computation. * layout.cc (Hash_task::Hash_task): Remove build_id_blocker, add Output_file and offset. (Hash_task::run): Get and release the input views. (Hash_task::is_runnable): Always return NULL (always runnable). (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters; use them instead of class members. (Build_id_task_runner::run): New function. (Close_task_runner::run): Pass array_of_hashes and size_of_hashes to write_build_id. * layout.h (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters. (Layout::array_of_hashes_): Remove. (Layout::size_of_array_of_hashes_): Remove. (Layout::input_view_): Remove. (Build_id_task_runner): New class. (Close_task_runner::Close_task_runner): Add array_of_hashes and size_of_hashes parameters. (Close_task_runner::array_of_hashes_): New data member. (Close_task_runner::size_of_hashes_): New data member. * testsuite/Makefile.am (flagstest_compress_debug_sections_and_build_id_tree): New test. * testsuite/Makefile.in: Regenerate.
Diffstat (limited to 'gold/layout.h')
-rw-r--r--gold/layout.h47
1 files changed, 31 insertions, 16 deletions
diff --git a/gold/layout.h b/gold/layout.h
index 9039ee8..4e29ba8 100644
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -897,16 +897,9 @@ class Layout
const Output_data_reloc_generic* dyn_rel,
bool add_debug, bool dynrel_includes_plt);
- // If a treehash is necessary to compute the build ID, then queue
- // the necessary tasks and return a blocker that will unblock when
- // they finish. Otherwise return BUILD_ID_BLOCKER.
- Task_token*
- queue_build_id_tasks(Workqueue* workqueue, Task_token* build_id_blocker,
- Output_file* of);
-
// Compute and write out the build ID if needed.
void
- write_build_id(Output_file*) const;
+ write_build_id(Output_file*, unsigned char*, size_t) const;
// Rewrite output file in binary format.
void
@@ -1380,12 +1373,6 @@ class Layout
Gdb_index* gdb_index_data_;
// The space for the build ID checksum if there is one.
Output_section_data* build_id_note_;
- // Temporary storage for tree hash of build ID.
- unsigned char* array_of_hashes_;
- // Size of array_of_hashes_ (in bytes).
- size_t size_of_array_of_hashes_;
- // Input view for computing tree hash of build ID. Freed in write_build_id().
- const unsigned char* input_view_;
// The output section containing dwarf abbreviations
Output_reduced_debug_abbrev_section* debug_abbrev_;
// The output section containing the dwarf debug info tree
@@ -1602,14 +1589,40 @@ class Write_after_input_sections_task : public Task
Task_token* final_blocker_;
};
+// This task function handles computation of the build id.
+// When using --build-id=tree, it schedules the tasks that
+// compute the hashes for each chunk of the file. This task
+// cannot run until we have finalized the size of the output
+// file, after the completion of Write_after_input_sections_task.
+
+class Build_id_task_runner : public Task_function_runner
+{
+ public:
+ Build_id_task_runner(const General_options* options, const Layout* layout,
+ Output_file* of)
+ : options_(options), layout_(layout), of_(of)
+ { }
+
+ // Run the operation.
+ void
+ run(Workqueue*, const Task*);
+
+ private:
+ const General_options* options_;
+ const Layout* layout_;
+ Output_file* of_;
+};
+
// This task function handles closing the file.
class Close_task_runner : public Task_function_runner
{
public:
Close_task_runner(const General_options* options, const Layout* layout,
- Output_file* of)
- : options_(options), layout_(layout), of_(of)
+ Output_file* of, unsigned char* array_of_hashes,
+ size_t size_of_hashes)
+ : options_(options), layout_(layout), of_(of),
+ array_of_hashes_(array_of_hashes), size_of_hashes_(size_of_hashes)
{ }
// Run the operation.
@@ -1620,6 +1633,8 @@ class Close_task_runner : public Task_function_runner
const General_options* options_;
const Layout* layout_;
Output_file* of_;
+ unsigned char* const array_of_hashes_;
+ const size_t size_of_hashes_;
};
// A small helper function to align an address.