This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] gold: extend Output_file to support read/write access to existing files.


> 2) I didn't see any reason to include the map_include_original_content_
> Â field.
  This was added to avoid such a scenario:
  1. The program opens a file with Output_file::open_for_modification,
the mapping succeeds.
  2. The programs calls Output_file::resize, this calls unmap() and map()
  3. Without map_include_original_content_, if inside
Output_file::map() mapping this file fails but anonymous mapping
succeeds, we loose all the contents of the file.

  I don't think this would happen often but could, in theory, happen
if e.g. the first map in 3. failed because of lack of address space
for the larger mapping but the second succeeded because another
threads freed some space between the calls.
  However, it seems this could also be a problem for new files created
with Output_file::open if someone wrote to them before calling
resize(). Maybe the solution is to change map to map_no_anonymous in
Output_file::resize?

MikoÅaj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]