[PATCH] D41619: [llvm-objcopy] Use physical instead of virtual address when aligning and placing sections in binary

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 17:51:46 PST 2018


jakehehrlich added a comment.

So Roland looked at this and said this seems reasonable to him. It should agree with our personal use case as well. I think between my testing, Owen looking and linking us to the BFD code, and Roland's approval I'm ok with this approach. This code LGTM but as always I'd like to wait for James for one last LGTM. Also I'm waiting for feed back on use of member pointers in llvm. Using rare little known features is generally frowned on so I wanted to make sure first.



================
Comment at: tools/llvm-objcopy/Object.cpp:377
 
+static bool compareSegmentsUsingPAddr(const Segment *A, const Segment *B) {
+  if (A->PAddr < B->PAddr)
----------------
I'm wondering if using a member point is ok here because it would let you dedup these two functions. Something like

```
compareSegmentsUsing(uint64_t Segment::*Member, const Segment *A, const Segment *B) {
  if (A->*Member < B->*Member)
    return true;
  if (A->*Member > B->*Member)
    return false;
  return A->Index < B->Index;
}
```

Then to pass the function you can use std::bind(compareSegmentsUsing, &Segment::PAddr)

This might be discouraged by llvm though since it's so uncommonly used that many people aren't aware of this feature.


https://reviews.llvm.org/D41619





More information about the llvm-commits mailing list