Skip to content

Commit 6136c58

Browse files
committed
3722 link-editor is over restrictive of R_AMD64_32 addends
Reviewed by: Gordon Ross <[email protected]> Reviewed by: Joshua M. Clulow <[email protected]> Approved by: Robert Mustacchi <[email protected]>
1 parent d8fa96c commit 6136c58

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

usr/src/cmd/sgs/packages/common/SUNWonld-README

+1
Original file line numberDiff line numberDiff line change
@@ -1646,3 +1646,4 @@ Bugid Risk Synopsis
16461646
3451 archive libraries with no symbols shouldn't require a string table
16471647
3616 SHF_GROUP sections should not be discarded via other COMDAT mechanisms
16481648
3709 need sloppy relocation for GNU .debug_macro
1649+
3722 link-editor is over restrictive of R_AMD64_32 addends

usr/src/uts/intel/amd64/krtld/doreloc.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ const Rel_entry reloc_table[R_AMD64_NUM] = {
175175
* entry
176176
*/
177177

178-
#define HIBITS 0xffffffff80000000ULL
178+
179+
/*
180+
* Bits that must be cleared or identical for a value to act as if extended in
181+
* the given way.
182+
*/
183+
#define ZEROEXBITS 0xffffffff00000000ULL
184+
#define SIGNEXBITS 0xffffffff80000000ULL
179185

180186
#if defined(_KERNEL)
181187
#define lml 0 /* Needed by arglist of REL_ERR_* macros */
@@ -244,10 +250,11 @@ do_reloc_rtld(uchar_t rtype, uchar_t *off, Xword *value, const char *sym,
244250
*/
245251
if (rtype == R_AMD64_32) {
246252
/*
247-
* Verify that this value will 'zero-extend', this
248-
* requires that the upper 33bits all be 'zero'.
253+
* Verify that this value will act as a zero-extended
254+
* unsigned 32 bit value. That is, that the upper
255+
* 32 bits are zero.
249256
*/
250-
if ((*value & HIBITS) != 0) {
257+
if ((*value & ZEROEXBITS) != 0) {
251258
/*
252259
* To keep chkmsg() happy:
253260
* MSG_INTL(MSG_REL_NOFIT)
@@ -258,12 +265,12 @@ do_reloc_rtld(uchar_t rtype, uchar_t *off, Xword *value, const char *sym,
258265
} else if ((rtype == R_AMD64_32S) || (rtype == R_AMD64_PC32) ||
259266
(rtype == R_AMD64_GOTPCREL) || (rtype == R_AMD64_GOTPC32)) {
260267
/*
261-
* Verify that this value will properly sign extend.
262-
* This is true of the upper 33bits are all either
263-
* 'zero' or all 'one'.
268+
* Verify that this value will act as a sign-extended
269+
* signed 32 bit value, that is that the upper 33 bits
270+
* are either all zero or all one.
264271
*/
265-
if (((*value & HIBITS) != HIBITS) &&
266-
((*value & HIBITS) != 0)) {
272+
if (((*value & SIGNEXBITS) != SIGNEXBITS) &&
273+
((*value & SIGNEXBITS) != 0)) {
267274
/*
268275
* To keep chkmsg() happy:
269276
* MSG_INTL(MSG_REL_NOFIT)

0 commit comments

Comments
 (0)