This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Fix RPathLC.cmdsize
ClosedPublic

Authored by sameerarora101 on Jun 10 2020, 7:44 AM.

Details

Summary

Add 1 to the cmdsize field under buildRPathLoadCommand in
MachOObjcopy.cpp to account for the NUL terminator. For
reference: the issue is highlighted in comments under
https://reviews.llvm.org/D81527.

Diff Detail

Event Timeline

sameerarora101 created this revision.Jun 10 2020, 7:44 AM
Herald added a project: Restricted Project. · View Herald Transcript

The change looks good, but it'd be helpful for the commit message to just contain the details about the issue directly instead of pointing to another review. (The + 1 is to account for the NUL terminator, as far as I can tell.)

Got it thanks, i'll update it

sameerarora101 edited the summary of this revision. (Show Details)Jun 10 2020, 10:59 AM
sameerarora101 edited the summary of this revision. (Show Details)
smeenai accepted this revision.Jun 10 2020, 12:39 PM

LGTM.

This revision is now accepted and ready to land.Jun 10 2020, 12:39 PM
smeenai resigned from this revision.Jun 10 2020, 12:40 PM

Hmm, actually, I think it should be possible to add a test for this? You'd need an rpath where the length of the string (not including the terminating NUL) was exactly a multiple of 8 for this to make a difference.

Resigning as reviewer to clear my accept.

This revision now requires review to proceed.Jun 10 2020, 12:40 PM
sameerarora101 updated this revision to Diff 270001.EditedJun 10 2020, 4:50 PM

Adding a test case for the change. String "abcd" has size 4 and sizeof(MachO::rpath_command) = 12. Since the sizes add up to 16, cmdsize should be assigned a size of 24 bytes if we take the NULL terminator into account.

This revision is now accepted and ready to land.Jun 10 2020, 10:31 PM
jhenderson accepted this revision.Jun 11 2020, 1:17 AM

LGTM, with nit.

llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
25

if -> that

(more clearly indicates that it is intended that it does account for the terminator)

sameerarora101 marked an inline comment as done.Jun 11 2020, 9:18 AM
This revision was automatically updated to reflect the committed changes.