X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fcommon.cc;h=b1348ecfbc7f3396a77451a28af1d8192fdc0779;hb=bb82aefe17866cdcb996ae35a3895bb36b4d674b;hp=8d122fa03f4ab1b96d017742e37be8f548804365;hpb=55455f8927ff9d4703d844163ef51b6e26cdef9e;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/common.cc b/gold/common.cc index 8d122fa03f..b1348ecfbc 100644 --- a/gold/common.cc +++ b/gold/common.cc @@ -1,6 +1,6 @@ // common.cc -- handle common symbols for gold -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2020 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -222,9 +222,6 @@ Symbol_table::do_allocate_commons_list( Mapfile* mapfile, Sort_commons_order sort_order) { - typedef typename Sized_symbol::Value_type Value_type; - typedef typename Sized_symbol::Size_type Size_type; - // We've kept a list of all the common symbols. But the symbol may // have been resolved to a defined symbol by now. And it may be a // forwarder. First remove all non-common symbols. @@ -286,12 +283,23 @@ Symbol_table::do_allocate_commons_list( gold_unreachable(); } - Output_data_space *poc = new Output_data_space(addralign, ds_name); - Output_section *os = layout->add_output_section_data(name, - elfcpp::SHT_NOBITS, - flags, poc, - ORDER_INVALID, - false); + Output_data_space* poc; + Output_section* os; + + if (!parameters->incremental_update()) + { + poc = new Output_data_space(addralign, ds_name); + os = layout->add_output_section_data(name, elfcpp::SHT_NOBITS, flags, + poc, ORDER_INVALID, false); + } + else + { + // When doing an incremental update, we need to allocate each common + // directly from the output section's free list. + poc = NULL; + os = layout->find_output_section(name); + } + if (os != NULL) { if (commons_section_type == COMMONS_SMALL) @@ -329,12 +337,26 @@ Symbol_table::do_allocate_commons_list( if (mapfile != NULL) mapfile->report_allocate_common(sym, ssym->symsize()); - off = align_address(off, ssym->value()); - ssym->allocate_common(poc, off); - off += ssym->symsize(); + if (poc != NULL) + { + off = align_address(off, ssym->value()); + ssym->allocate_common(poc, off); + off += ssym->symsize(); + } + else + { + // For an incremental update, allocate from the free list. + off = os->allocate(ssym->symsize(), ssym->value()); + if (off == -1) + gold_fallback(_("out of patch space in section %s; " + "relink with --incremental-full"), + os->name()); + ssym->allocate_common(os, off); + } } - poc->set_current_data_size(off); + if (poc != NULL) + poc->set_current_data_size(off); commons->clear(); }