Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8205104

EXTRA_LDFLAGS not consistently being used

    XMLWordPrintable

Details

    • b01
    • generic

    Backports

      Description

        This is a JDK 8 specific problem. JDK 11 with the new build system passes extra C flags and linker flags down correctly, when the various libraries are being built. JDK 10 had one problem which got fixed with JDK-8202262.

        For a JDK 8 build with something like this:
        configure [...] --with-extra-cxxflags=X --with-extra-cflags=Y --with-extra-ldflags=Z

        And X == Y == "-std=gnu++98 -fno-delete-null-pointer-checks -fno-lifetime-dse" and Z == "-Wl,-z,relro -Wl,-z,now ", X, Y flags are correctly passed to the build. Z flags on the other hand not.

        For example:
        configure [...] --with-extra-ldflags=-Wl,-z,relro -Wl,-z,now -specs=/disk/openjdk/upstream-sources/openjdk8u-dev/hardened-ld

        Then when linking libjvm.so I see:
            /usr/bin/gcc -m64 -Xlinker -O1 -Wl,--hash-style=both -g -pipe -Wformat -Wno-cpp -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/disk/openjdk/upstream-sources/openjdk8u-dev/hardened-cc1 -specs=/disk/openjdk/upstream-sources/openjdk8u-dev/annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -std=gnu++98 -Wno-error -fno-delete-null-pointer-checks -fno-lifetime-dse -std=gnu++98 -Xlinker -z -Xlinker noexecstack -shared \
        -Xlinker --version-script=mapfile_reorder -Xlinker -soname=libjvm.so -o libjvm.so abstractCompiler.o accessFlags.o ad_x86_64.o ad_x86_64_clone.o ad_x86_64_expand.o ad_x86_64_format.o ad_x86_64_gen.o ad_x86_64_misc.o ad_x86_64_peephole.o ad_x86_64_pipeline.o adaptiveFreeList.o adaptiveSizePolicy.o addnode.o adjoiningGenerations.o adjoiningVirtualSpaces.o advancedThresholdPolicy.o ageTable.o allocTracer.o allocation.o allocationStats.o altHashing.o annotations.o arguments.o array.o arrayKlass.o arrayOop.o asPSOldGen.o asPSYoungGen.o asParNewGeneration.o assembler.o assembler_linux_x86.o assembler_x86.o atomic.o attachListener.o attachListener_linux.o barrierSet.o basicLock.o bcEscapeAnalyzer.o biasedLocking.o binaryTreeDictionary.o bitMap.o block.o blockOffsetTable.o bufferingOopClosure.o buildOopMap.o bytecode.o bytecodeAssembler.o bytecodeHistogram.o bytecodeInfo.o bytecodeInterpreter.o bytecodeInterpreterWithChecks.o bytecodeInterpreter_x86.o bytecodeStream.o bytecodeTracer.o bytecodes.o bytecodes_x86.o c1_CFGPrinter.o c1_Canonicalizer.o c1_CodeStubs_x86.o c1_Compilation.o c1_Compiler.o c1_Defs.o c1_FpuStackSim_x86.o c1_FrameMap.o c1_FrameMap_x86.o c1_GraphBuilder.o c1_IR.o c1_Instruction.o c1_InstructionPrinter.o c1_LIR.o c1_LIRAssembler.o c1_LIRAssembler_x86.o c1_LIRGenerator.o c1_LIRGenerator_x86.o c1_LinearScan.o c1_LinearScan_x86.o c1_MacroAssembler_x86.o c1_Optimizer.o c1_RangeCheckElimination.o c1_Runtime1.o c1_Runtime1_x86.o c1_ValueMap.o c1_ValueSet.o c1_ValueStack.o c1_ValueType.o c1_globals.o c2_globals.o c2_init_x86.o c2compiler.o cSpaceCounters.o callGenerator.o callnode.o cardTableExtension.o cardTableModRefBS.o cardTableRS.o cfgnode.o chaitin.o chunkedList.o ciArray.o ciArrayKlass.o ciBaseObject.o ciCallSite.o ciConstant.o ciConstantPoolCache.o ciEnv.o ciExceptionHandler.o ciField.o ciFlags.o ciInstance.o ciInstanceKlass.o ciKlass.o ciMemberName.o ciMetadata.o ciMethod.o ciMethodBlocks.o ciMethodData.o ciMethodHandle.o ciNullObject.o ciObjArray.o ciObjArrayKlass.o ciObject.o ciObjectFactory.o ciReplay.o ciSignature.o ciStreams.o ciSymbol.o ciType.o ciTypeArray.o ciTypeArrayKlass.o ciTypeFlow.o ciUtilities.o classFileError.o classFileParser.o classFileStream.o classLoader.o classLoaderData.o classLoaderStats.o classLoadingService.o classes.o cmsAdaptiveSizePolicy.o cmsCollectorPolicy.o cmsGCAdaptivePolicyCounters.o cmsLockVerifier.o coalesce.o codeBlob.o codeBuffer.o codeCache.o collectedHeap.o collectionSetChooser.o collectorCounters.o collectorPolicy.o compactibleFreeListSpace.o compilationPolicy.o compile.o compileBroker.o compileLog.o compiledIC.o compiledICHolder.o compiledIC_x86.o compilerOracle.o compressedStream.o concurrentG1Refine.o concurrentG1RefineThread.o concurrentGCThread.o concurrentMark.o concurrentMarkSweepGeneration.o concurrentMarkSweepThread.o concurrentMarkThread.o connode.o constMethod.o constantPool.o constantTag.o copy.o cpCache.o cppInterpreter.o cppInterpreter_x86.o debug.o debugInfo.o debugInfoRec.o debug_x86.o decoder.o decoder_elf.o decoder_linux.o defNewGeneration.o defaultMethods.o deoptimization.o depChecker_x86.o dependencies.o dfa_x86_64.o diagnosticArgument.o diagnosticCommand.o diagnosticFramework.o dict.o dictionary.o dirtyCardQueue.o disassembler.o divnode.o doCall.o domgraph.o dtraceAttacher.o dtraceJSDT.o dtraceJSDT_linux.o elfFile.o elfFuncDescTable.o elfStringTable.o elfSymbolTable.o errorReporter.o escape.o events.o evmCompat.o exceptionHandlerTable.o exceptions.o fieldDescriptor.o fieldType.o filemap.o forte.o fprofiler.o frame.o frame_x86.o freeBlockDictionary.o freeChunk.o freeList.o g1AllocRegion.o g1Allocator.o g1Allocator_ext.o g1BiasedArray.o g1BlockOffsetTable.o g1CardCounts.o g1CodeCacheRemSet.o g1CollectedHeap.o g1CollectedHeap_ext.o g1CollectorPolicy.o g1ErgoVerbose.o g1GCPhaseTimes.o g1HRPrinter.o g1HotCardCache.o g1Log.o g1MMUTracker.o g1MarkSweep.o g1MarkSweep_ext.o g1MemoryPool.o g1MonitoringSupport.o g1OopClosures.o g1PageBasedVirtualSpace.o g1ParScanThreadState.o g1RegionToSpaceMapper.o g1RemSet.o g1RemSetSummary.o g1RootProcessor.o g1SATBCardTableModRefBS.o g1StringDedup.o g1StringDedupQueue.o g1StringDedupStat.o g1StringDedupTable.o g1StringDedupThread.o g1_globals.o gSpaceCounters.o gcAdaptivePolicyCounters.o gcCause.o gcId.o gcLocker.o gcNotifier.o gcPolicyCounters.o gcStats.o gcTaskManager.o gcTaskThread.o gcTimer.o gcTrace.o gcTraceSend.o gcTraceTime.o gcUtil.o gcm.o genCollectedHeap.o genMarkSweep.o genRemSet.o generateOopMap.o generateOptoStub.o generation.o generationCounters.o generationSizer.o generationSpec.o globalDefinitions.o globals.o graphKit.o growableArray.o guardedMemory.o hSpaceCounters.o handles.o hashtable.o heap.o heapDumper.o heapInspection.o heapRegion.o heapRegionManager.o heapRegionRemSet.o heapRegionSet.o heapRegionType.o histogram.o icBuffer.o icBuffer_x86.o icache.o icache_x86.o idealGraphPrinter.o idealKit.o ifg.o ifnode.o immutableSpace.o indexSet.o init.o instanceClassLoaderKlass.o instanceKlass.o instanceMirrorKlass.o instanceOop.o instanceRefKlass.o intHisto.o interfaceSupport.o interp_masm_x86.o interp_masm_x86_64.o interpreter.o interpreterRT_x86_64.o interpreterRuntime.o interpreter_x86_64.o invocationCounter.o iterator.o java.o javaAssertions.o javaCalls.o javaClasses.o jni.o jniCheck.o jniFastGetField.o jniFastGetField_x86_64.o jniHandles.o jniPeriodicChecker.o jvm.o jvm_linux.o jvmtiClassFileReconstituter.o jvmtiCodeBlobEvents.o jvmtiEnter.o jvmtiEnterTrace.o jvmtiEnv.o jvmtiEnvBase.o jvmtiEnvThreadState.o jvmtiEventController.o jvmtiExport.o jvmtiExtensions.o jvmtiGetLoadedClasses.o jvmtiImpl.o jvmtiManageCapabilities.o jvmtiRawMonitor.o jvmtiRedefineClasses.o jvmtiTagMap.o jvmtiThreadState.o jvmtiTrace.o jvmtiUtil.o klass.o klassVtable.o lcm.o library_call.o linkResolver.o linkedlist.o linux_x86_64.o live.o loaderConstraints.o location.o locknode.o loopPredicate.o loopTransform.o loopUnswitch.o loopnode.o loopopts.o lowMemoryDetector.o machnode.o macro.o macroAssembler_x86.o mallocSiteTable.o mallocTracker.o management.o markOop.o markSweep.o matcher.o mathexactnode.o memBaseline.o memRegion.o memReporter.o memTracker.o memnode.o memoryManager.o memoryPool.o memoryService.o memprofiler.o metachunk.o metadata.o metadataOnStackMark.o metaspace.o metaspaceCounters.o metaspaceShared.o metaspaceShared_x86_64.o metaspaceTracer.o method.o methodComparator.o methodCounters.o methodData.o methodHandles.o methodHandles_x86.o methodLiveness.o monitorChunk.o mulnode.o multnode.o mutableNUMASpace.o mutableSpace.o mutex.o mutexLocker.o mutex_linux.o nativeCallStack.o nativeInst_x86.o nativeLookup.o nmethod.o nmtCommon.o nmtDCmd.o node.o numberSeq.o objArrayKlass.o objArrayOop.o objectCountEventSender.o objectMonitor.o objectStartArray.o oop.o oopFactory.o oopMap.o oopMapCache.o oopRecorder.o oopsHierarchy.o opcodes.o orderAccess.o os.o osThread.o osThread_linux.o os_linux.o os_linux_x86.o os_posix.o ostream.o output.o parCardTableModRefBS.o parGCAllocBuffer.o parMarkBitMap.o parNewGeneration.o parallelScavengeHeap.o park.o parse1.o parse2.o parse3.o parseHelper.o parserTests.o pcDesc.o pcTasks.o perf.o perfData.o perfMemory.o perfMemory_linux.o phase.o phaseX.o placeholders.o port.o postaloc.o preserveException.o privilegedStack.o promotionInfo.o psAdaptiveSizePolicy.o psCompactionManager.o psGCAdaptivePolicyCounters.o psGenerationCounters.o psMarkSweep.o psMarkSweepDecorator.o psMemoryPool.o psOldGen.o psParallelCompact.o psPromotionLAB.o psPromotionManager.o psScavenge.o psTasks.o psVirtualspace.o psYoungGen.o ptrQueue.o quickSort.o referencePolicy.o referenceProcessor.o reflection.o reflectionUtils.o reg_split.o regalloc.o register.o register_definitions_x86.o register_x86.o regmask.o relocInfo.o relocInfo_x86.o relocator.o replacednodes.o resolutionErrors.o resourceArea.o rewriter.o rframe.o rootnode.o rtmLocking.o runtime.o runtimeService.o runtime_x86_64.o safepoint.o satbQueue.o scopeDesc.o serviceThread.o set.o sharedHeap.o sharedPathsMiscInfo.o sharedRuntime.o sharedRuntimeTrans.o sharedRuntimeTrig.o sharedRuntime_x86_64.o signature.o simpleThresholdPolicy.o sizes.o space.o spaceCounters.o spaceDecorator.o sparsePRT.o specialized_oop_closures.o split_if.o stackMapFrame.o stackMapTable.o stackValue.o stackValueCollection.o statSampler.o stringUtils.o stringopts.o stubCodeGenerator.o stubGenerator_x86_64.o stubRoutines.o stubRoutines_linux.o stubRoutines_x86.o stubRoutines_x86_64.o stubs.o subnode.o superword.o survRateGroup.o suspendibleThreadSet.o sweeper.o symbol.o symbolTable.o synchronizer.o systemDictionary.o task.o taskqueue.o templateInterpreter.o templateInterpreter_x86.o templateInterpreter_x86_64.o templateTable.o templateTable_x86_64.o tenuredGeneration.o thread.o threadCritical_linux.o threadLS_linux_x86.o threadLocalAllocBuffer.o threadLocalStorage.o threadService.o thread_ext.o thread_linux_x86.o ticks.o timer.o type.o typeArrayKlass.o typeArrayOop.o unhandledOops.o universe.o unsafe.o utf8.o vectornode.o vectset.o verificationType.o verifier.o vframe.o vframeArray.o vframe_hp.o virtualMemoryTracker.o virtualspace.o vmCMSOperations.o vmError.o vmError_linux.o vmGCOperations.o vmPSOperations.o vmStructs.o vmSymbols.o vmThread.o vm_operations.o vm_operations_g1.o vm_version.o vm_version_linux_x86.o vm_version_x86.o vmreg.o vmreg_x86.o vtableStubs.o vtableStubs_x86_64.o whitebox.o whitebox_ext.o workgroup.o xmlstream.o yieldingWorkgroup.o -lstdc++ -lm -ldl -lpthread;

        There is no "-Wl,-z,now" and other options. The same applies to libjsig and libsaproc. This is a problem when attempting to produce a hardened build of OpenJDK 8. For example it's expected for a build with "-Wl,-z,now" in extra-ldflags to produce libjvm.so with BIND_NOW, but is not:

        $ readelf -d build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/server/libjvm.so | grep NOW
        <nothing>

        Attachments

          Issue Links

            Activity

              People

                sgehwolf Severin Gehwolf
                sgehwolf Severin Gehwolf
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: