This is the mail archive of the binutils@sources.redhat.com 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]

Re: Clean up platform-specific code in gas/write.c



  In message <orog2txa48.fsf@guarana.lsd.ic.unicamp.br>you write:
  > --=-=-=
  > 
  > This patch cleans up a growing chunk of platform-specific code in
  > gas/write.c, setting a precedent so that people do it right next time.
  > I'd rather not have to create yet another platform-specific #define,
  > but at least one other platform compensates for this code elsewhere,
  > so they'll have to be cleaned up one by one.
  > 
  > I confess I haven't tested this patch on all of the affected
  > platforms, but I did it on the ones I considered most relevant, and it
  > worked fine as long as my test went (it wasn't very thorough either
  > :-(
  > 
  > I'd appreciate if maintainers of the specific platforms could either
  > test it more thoroughly or ask to have their platform kept out of the
  > change for now (i.e., the ugly #ifdef would remain in place and the
  > new #define wouldn't be introduced) until they cleaned it up by
  > themselves.
  > 
  > That put, ok to install?
  > 
  > 
  > --=-=-=
  > Content-Type: text/x-patch
  > Content-Disposition: inline; filename=gas-defer-fixup.patch
  > 
  > Index: gas/ChangeLog
  > from  Alexandre Oliva  <aoliva@redhat.com>
  > 
  > 	* write.c (fixup_segment) [TC_DONT_FIX_NON_ADJUSTABLE]: Use
  > 	obj_fix_adjustable() and tc_fix_adjustable() to tell whether to
  > 	add a symbol's address.  Removed all target-specific #ifdefs that
  > 	used to accomplished the same.
  > 	* config/tc-v850.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
  > 	* config/tc-m68k.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
  > 	* config/tc-arm.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
  > 	* config/tc-i960.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
  > 	* config/tc-i386.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
A note for those not familiar with this code.

The reason we didn't just check obj_fix_adjustable and tc_fix_adjustable
is because some targets depend on fixup_segment updating ADD_NUMBER,
even for fixups which will turn into relocations.

The long term plan is to grovel over those targets' definition of
md_apply_fix and fix them up -- which would eventually allow 
TC_DONT_FIX_NON_ADJUSTABLE to go away.  But for now we'll keep it to
avoid accidentally breaking a lot of ports.

--

The *_fix_adjustable macros are supposed to tell the assembler when it
can adjust a fixup so that it uses a section symbol + offset instead of
the original symbol for the fixup.

ie, Let's say we had a fixup which referenced symbol fubar with an addend
of 24 and we know that fubar is at offset 8 within its section (.text for
the sake of argument).

The original fixup was fubar + 24; however, the assembler will generally
try to transform that into .text + 32.

I don't know all the reasons behind this behavior, though it does have
at least one positive effect -- it can shrink the size of a .o file as
certain symbols may disappear if they're not referenced by relocs.

Anyway, over time people realize that this behavior wasn't actually always
desirable.  Sometimes this was due to target dependent issues, others due
to object format issues, etc.  Thus the invention of *_fix_adjustable.

jeff


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