This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD] PowerPC64 TOC indirect to TOC relative code editing
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 9 Jan 2017 09:29:24 -0800
- Subject: Re: [GOLD] PowerPC64 TOC indirect to TOC relative code editing
- Authentication-results: sourceware.org; auth=none
- References: <20170108101404.GU31129@bubble.grove.modra.org>
> + if (start == 0)
> + start = 1;
> + if (start >= shnum)
> + return;
Isn't (start >= shnum) a "can't happen" case? Why not just
gold_assert(start < shnum)?
> + unsigned int i = start;
> + do
> {
> + const unsigned char* p = pshdrs + i * This::shdr_size;
> ...
> + } while ((i = i + 1 == shnum ? 1 : i + 1) != start);
> }
Not a fan of that do...while loop. (Hmmm, what happens if shnum == 1?)
At the least, the condition could use an extra pair of parens to make
it more readable. I think I'd prefer the original for loop, running
from 1..shnum, but add the bias and calculate p at the top of the
loop.
-cary